The pandas to_json
function for some reason is converting the index of the dataframe into strings. Is there a way to avoid this?
>>> import pandas as pd
>>> df = pd.DataFrame({"a" : [1,2,3], "b" : [2,3,4]})
>>> df.to_json(orient = "index")
'{"0":{"a":1,"b":2},"1":{"a":2,"b":3},"2":{"a":3,"b":4}}'
>>> import json
>>> json.loads(df.to_json(orient="index"))
{'2': {'a': 3, 'b': 4}, '1': {'a': 2, 'b': 3}, '0': {'a': 1, 'b': 2}}
>>>