Last active
November 8, 2019 21:09
-
-
Save justinr922/99b88f0f932c184b94cdab2f780f3e23 to your computer and use it in GitHub Desktop.
Converts Location Column to "Latitude" and "Longitude" columns
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Each coordinate is in the form of a dictionary like so: | |
# | |
# {'latitude': 34.3, 'longitude': -89.5} | |
# | |
# So we will use list compreshension to create a new column, | |
# using dictionary.get(key) to access each value. | |
location_df['latitude'] = [value.get('latitude') for value in location_df['coordinate']] | |
location_df['longitude'] = [value.get('longitude') for value in location_df['coordinate']] | |
#And drop the old coordinate column, since we have gotten what we need out of it | |
location_df.drop('coordinate', axis=1, inplace=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment