1>>> result = df.to_json(orient="index")
2>>> parsed = json.loads(result)
3>>> json.dumps(parsed, indent=4)
4{
5 "row 1": {
6 "col 1": "a",
7 "col 2": "b"
8 },
9 "row 2": {
10 "col 1": "c",
11 "col 2": "d"
12 }
13}
14