pythonpandasdataframenumpystack

Convert crosstab data into stacked table using python


Input enter image description here

Output Required enter image description here

I tried df = df.stack() but its not showing date as separate column.


Solution

  • Transform your data to pandas dataframe (df) and use:

     import pandas as pd
     pd.melt(df, id_vars=['Date'])