I have a DataFrame named distinct_values:
gender purchase_frequency
0 Female Low
1 Male Mid
2 Male High
3 Female Mid
4 Female High
5 Male Low
I now want to convert each column of this dataframe into a dictionary where name of the dictionary is based on column name:
gender={'Female', 'Male', 'Male', 'Female', 'Female', 'Male'}
purchase_frequency= {'Low', 'Mid', 'High', 'Mid', 'High', 'Low'}
I have tried the following method but this combined the dataframe to a single dictionary of lists and that wasn't desired:
df_dict = dict(zip([i for i in distinct_values.columns] , [pd.DataFrame(distinct_values[i].unique(), columns=[i]) for i in distinct_values.columns]))
Please let me know if there is a solution to this