I have a Json string from which I\'m able to extract few components like formatted_address
,lat
,lng
, but I\'m unable to extract feature(val
This is rather a pretty broad question...
To help you to start:
record_path = ['address_components']
meta= [
'formatted_address',
['geometry','location','lat'],
['geometry','location','lng'],
]
x = pd.io.json.json_normalize(d['results'], record_path, meta)
Result:
In [20]: pd.options.display.max_rows = 15
In [21]: x
Out[21]:
long_name short_name types \
0 Satya Niwas Satya Niwas [establishment, point_of_interest, premise]
1 Kanti Nagar Kanti Nagar [political, sublocality, sublocality_level_3]
2 J B Nagar J B Nagar [political, sublocality, sublocality_level_2]
3 Andheri East Andheri East [political, sublocality, sublocality_level_1]
4 Mumbai Mumbai [locality, political]
5 Mumbai Suburban Mumbai Suburban [administrative_area_level_2, political]
6 Maharashtra MH [administrative_area_level_1, political]
.. ... ... ...
83 India IN [country, political]
84 400047 400047 [postal_code]
85 Andheri East Andheri East [political, sublocality, sublocality_level_1]
86 Mumbai Mumbai [locality, political]
87 Mumbai Suburban Mumbai Suburban [administrative_area_level_2, political]
88 Maharashtra MH [administrative_area_level_1, political]
89 India IN [country, political]
formatted_address geometry.location.lat geometry.location.lng
0 Satya Niwas, Kanti Nagar, J B Nagar, Andheri E... 19.109659 72.867471
1 Satya Niwas, Kanti Nagar, J B Nagar, Andheri E... 19.109659 72.867471
2 Satya Niwas, Kanti Nagar, J B Nagar, Andheri E... 19.109659 72.867471
3 Satya Niwas, Kanti Nagar, J B Nagar, Andheri E... 19.109659 72.867471
4 Satya Niwas, Kanti Nagar, J B Nagar, Andheri E... 19.109659 72.867471
5 Satya Niwas, Kanti Nagar, J B Nagar, Andheri E... 19.109659 72.867471
6 Satya Niwas, Kanti Nagar, J B Nagar, Andheri E... 19.109659 72.867471
.. ... ... ...
83 J B Nagar, Andheri East, Mumbai, Maharashtra 4... 19.111062 72.865592
84 J B Nagar, Andheri East, Mumbai, Maharashtra 4... 19.111062 72.865592
85 Andheri East, Mumbai, Maharashtra, India 19.115491 72.872695
86 Andheri East, Mumbai, Maharashtra, India 19.115491 72.872695
87 Andheri East, Mumbai, Maharashtra, India 19.115491 72.872695
88 Andheri East, Mumbai, Maharashtra, India 19.115491 72.872695
89 Andheri East, Mumbai, Maharashtra, India 19.115491 72.872695
[90 rows x 6 columns]