1

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?

phoenix
  • 111
  • 1
  • 1
  • 3

3 Answers3

1

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')
A Kareem
  • 863
  • 7
  • 11
0

You can use the pd.DataFrame.from_records() method like:

pd.DataFrame.from_records(data)
Stephen Rauch
  • 1,831
  • 11
  • 23
  • 34
zi guo
  • 1
0

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)

enter image description here