I have the following dataframe that I try to 'melt'.
So my aim is to get a output with 2 column
- Column name
- Value
So my output should look like [that's only the head of the output, I don't show it fully to be concise]
I have tried the following but it not works.
df2 = pd.melt(df, id_vars=df.index, var_name="Name", value_name="Value")
It says: KeyError: "The following 'id_vars' are not present in the DataFrame:
PS: The columns are 'predictors' so if not too complicated I would be happy to add a P as prexix in the column name like P0 P1 P2 P3 P4 P5