# fast processing: changing the column value in a geospatial environment

I have a table whose header looks like this: complaint_type, borough, street_name, incident_zip, latitude, longitude

1) I want to check if the "incident_zip" column of each row is in a specific list of zip codes and change the "borough" accordingly. There is a large amount of data and i cannot find any better code to do this. I am using python 3.6. I want to change the borough where it is "unspecified". I used if statements along with replace but it is taking a lot of processing time (more than 3hrs) that I have to stop the kernel. There are five long lists of zip codes.

2) Is there any other way to update the "borough" column like latitude and longitude?

• So you have zip code to borough mapping? Nov 10 '19 at 12:39

This is to get whether the incident_zip is in the list of zip code.

df.isin({'incident_zip' : zip_code_list)


If you have a zip code borough mapping in the form of dict. You can do

df['borough'].map(zip_to_borough)


For pandas dataframe never iterate say by rows unless as last resort because the performance will be terrible.

You can speed these operation multiprocessing if you want.