I create an OrderedDict:
from collections import OrderedDict
od = OrderedDict([((2, 9), 0.5218),
((2, 0), 0.3647),
((3, 15), 0.3640),
((3, 8), 0.3323),
((2, 28), 0.3310),
((2, 15), 0.3281),
((2, 10), 0.2938),
((3, 9), 0.2719)])
Then I feed that into the pandas DataFrame constructor:
import pandas as pd
df = pd.DataFrame({'values': od})
the result is this:
instead it should give this:
What is going on here that I don't understand?
P.S.: I am not looking for an alternative way to solving the problem (though you are welcome to post it if you think it would help the community). All I want is to understand why this here doesn't work. Is it a bug, or is there some logic to it? This is also not a duplicate of this link, because i am using specifically an OrderedDict and not a normal dict.