I have a pandas dataframe that looks something like this:
df=pd.DataFrame({'a':['A','B','C','A'], 'b':[1,4,1,3], 'c':[0,6,1,0], 'd':[1,0,0,5]})
I want a dataframe that will look like this:
The original dataframe was grouped by values in column 'a' and its corresponding values are saved as a dictionary in a new column 'dict'. The key - value pairs are the column name and values in the column respectively. In case if a value in column 'a' has multiple entries (for eg A in column 'a' occurs twice), then a list of dictionary should be created for the same value.
How can I do this ?(Please ignore the grammatical mistakes and please ask any doubts regarding the question if it sounded too vague)