Assume I have df below:
df = pd.DataFrame({
'A': ['a', 'b'],
'B': [1, 2],
'C': [3, 4]
})
How can I turn this into a nested dict of the format:
{'a': {'B': 1, 'C': 2}, 'b': {'B': 3, 'C': 4}}
I've tried df.to_dict() which doesn't return the format I'm after.
Thanks!