Pandas dataframe to json without index
You can use orient='records'
print df.reset_index().to_json(orient='records')[ {"id":0,"location":"[50, 50]"}, {"id":1,"location":"[60, 60]"}, {"id":2,"location":"[70, 70]"}, {"id":3,"location":"[80, 80]"}]
Since 2017 there is an index=False
option. Use it with orient='split'
or orient='table'
. Credit to this answer on a similar question: https://stackoverflow.com/a/59438648/1056563
dfj = json.loads(df.to_json(orient='table',index=False))