Right now I have a DataFrame df2 that looks like this:
Kuwaiti Non-Kuwaiti Total
Age
0-4 164483 156459 320942
5-9 158377 136935 295312
When I do:
df2.to_json()
I get:
'{"Kuwaiti":{"0-4":164483,"5-9":158377},"Non-Kuwaiti":{"0-4":156459,"5-9":136935},"Total":{"0-4":320942,"5-9":295312}}'
As you can see, df2.index.name is not preserved anywhere.
What can I do to preserve the index name?