Extracting longitude and latitude
A DataFrame named df has been pre-loaded for you. Complete the code to extract longitude and latitude to new, separate columns.
यह अभ्यास पाठ्यक्रम का हिस्सा है
Visualizing Geospatial Data in Python
अभ्यास निर्देश
- Print the first few rows with
print()anddf.head(). - Use a list comprehension to extract latitude to a new column called
lat. - Use a list comprehension to extract longitude to a new column called
lng. - Print the first few rows with
print()anddf.head()again to confirm the new columns.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# print the first few rows of df
print(df.head())
# extract latitude to a new column: lat
df['lat'] = [loc[_____] for loc in df.Location]
# extract longitude to a new column: lng
df['lng'] = [loc[_____] for loc in df.Location]
# print the first few rows of df again
print(df.head())