I have a pandas dataframe called new_df, and it has these columns:
I want to I want to pivot this table so that the values in "Number" are turned into columns, while Name, Area, Buy_Date, Sell_Date, and End_date become rows which are under the column User_Information. So the new table should look like this:
My code is roughly like this so far:
pivoted_df = new_df.pivot_table( index=['ID', 'Shop', 'User_Information'], columns='Number', values=['NAME', 'Area', 'Buy_Date', 'Sell_Date', 'End_Date'] )But this doesn't seem to work in the way I want it, so if anyone could help me fix it I would greatly appreciate it, thank you!
My issue differs from the link given here:
How do I melt a pandas dataframe?
since I actually want to fill-in the information underneath the User_Information column. In addition, it also differs from it since the the values under Number can vary, for example, for a specific ID and Shop one of them might have only 1 column, while the one after it might have 5 etc.

