Data Science Asked on July 22, 2021
I have a json array f below format
[{
'Address': 'xxx',
'Latitude': 28. xxx,
'Longitude': 77. xxx,
'reached': False
}, {
'Address': 'yyy',
'Latitude': 18. yyy,
'Longitude': 73. yyy,
'reached': False
}]
i want to convert into dataframe. if the column name is same it should have (Address_0, Address_1 etc) and should be side by side, not below. How can i do this?
Have you tried using the pandas.read_json
method? (documentation)
And it looks like your json is structured like 'records'
so use
pd.read_json(_, orient='records')
Answered by A Kareem on July 22, 2021
You can use the pd.DataFrame.from_records()
method like:
pd.DataFrame.from_records(data)
Answered by zi guo on July 22, 2021
Please use pd.json_normalize(data)
. It normalizes json structure into flat table of data:
data = [{
'Address': 'xxx',
'Latitude': 28.000,
'Longitude': 77.000,
'reached': False}, {
'Address': 'yyy',
'Latitude': 18.000,
'Longitude': 73.000,
'reached': False}]
pd.json_normalize(data)
Answered by Edward Weinert on July 22, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP