Longitude और latitude निकालना
आपके लिए df नाम का एक DataFrame पहले से लोड किया गया है. longitude और latitude को नई, अलग-अलग कॉलमों में निकालने के लिए कोड पूरा करें.
यह अभ्यास पाठ्यक्रम का हिस्सा है
Python में Geospatial Data का Visualization
अभ्यास निर्देश
print()औरdf.head()के साथ शुरुआती कुछ पंक्तियाँ प्रिंट करें.- एक list comprehension का उपयोग करके latitude को
latनाम की नई कॉलम में निकालें. - एक list comprehension का उपयोग करके longitude को
lngनाम की नई कॉलम में निकालें. - नई कॉलमों की पुष्टि करने के लिए
print()औरdf.head()के साथ फिर से शुरुआती कुछ पंक्तियाँ प्रिंट करें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# 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())