I Have a Excel Data Like This
Category Item
old apple
new mango
old grape
new ginger
I need to get that data in python using pandas in the dictionary format like -
{'old': ['apple', 'grape'], 'new': ['mango', ginger']}
From one of the references from stack overflow They provide code like this
import pandas as pd
df = pd.read_excel("Skills.xlsx", index_col=0)
df = df.where(pd.notnull(df), None)
print(df.to_dict())
I am getting like output like:
{'Skills': {'old': 'grape', 'new': 'ginger'}}
But I need the output like this:
{'Skills': {'old': ['apple', 'grape'], 'new': ['mango', ginger']}}