Python Forum

Full Version: Converting raw data into panel data
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a problem about converting raw data into panel data.
I got the following data in excel like:
Name MMMmarketcap MMMstoctprice APPLmarketcap APPLstoctprice ... (i)marketcap (i)stockprice
01/2001 a1 b1 c1 d1
.... ... ... ... ...
05/2018 an bn ... ...
How can I convert the data into panel format like:
Date Name MarketCap Stock Price
01/2001 MMM a1 b1
....
05/2018
01/2001 AAPL c1 d1
....
05/2018
I try but i cannot get the result expected :
df1 = pd.melt(df,id_vars=["Name"])
I got something like:
Name Variable Value
01/2001 MMMmarketcap a1
....
05/2018 MMMmarketcap an
01/2011 MMMstockprice b1
....
05/2018 MMM stockprice bn

Many thanks for helping.
why are you running subject words together? It's annoying and not necessary