I have dict with tuple key:
td=[((1, 1), 1), ((1, 2), 2), ((1, 3), 1) ((2, 1), 1), ((2, 2), 5), ((3, 2), 2]
I want to create the table like below: (using tuple as index)
1 2 3
1 1 2 1
2 2 5 2
3 1 0 0
How can I create this table by using python?
I tried pd.MultiIndex, but it was not working.
Thanks.
I think this way .
pd.Series(dict(td)).reset_index()
Out[115]:
level_0 level_1 0
0 1 1 1
1 1 2 2
2 1 3 1
3 2 1 1
4 2 2 5
5 3 1 1
6 3 2 2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With