I have the DF of this kind: And I need to convert to this: I need to keep label for unique value and keys are merged to the right if present in the data. Keys may vary and be of different names for one value. Feel free to share how to rename the question because I could not find the
Tag: transpose
How to switch columns rows in a pandas dataframe
I have the following dataframe: I tried with pivot table but I get the following error: any alternative to pivot table to do this? Answer You can use df = df.T to transpose the dataframe. This switches the dataframe round so that the rows become columns. You could also use pd.DataFrame.transpose().