dataframe to dictionary with one column as key
pd.Series(df.A.values,index=df.B).to_dict()
dataframe to dictionary with one column as key
pd.Series(df.A.values,index=df.B).to_dict()
convert pandas dataframe to dict with a column as key
df.set_index('columnName').T.to_dict()
dataframe to dict without index
{'Name': ['John', 'Sara', 'John', 'Sara'],
'Sem': ['Sem1', 'Sem1', 'Sem2', 'Sem2'],
'Subject': ['Mathematics', 'Biology', 'Biology', 'Mathematics'],
'Grade': ['A', 'B', 'A+', 'B++']}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us