I have a dataframe:
accountname ip
0 aa 10.1.1.1
1 bb 10.1.1.2
2 cc 10.1.1.3
I want a json like this:
{ 'aa':{'ip':'10.1.1.1'}, 'bb':{'ip':'10.1.1.2'},'cc':{'ip':'10.1.1.3'}}
But with
df.index.name = 'accountname'
df.reset_index(drop=True)
json = df.to_json(orient='index')
I have old index in json. Any advive would be appreciated.