I have a dataframe with more descriptions for products.
data = {'product': ['1234', '5678'],
'descriptionOLD': ['old1234', 'old5678'],
'descriptionNEW': ['new1234', 'new5678'],
'descriptionFUTURE': ['future1234', 'future5678'],
}
How can i split this dataframe in this kind of format?
product type description
1234 descriptionOLD old1234
1234 descriptionOLD old5678
1234 descriptionNEW new1234
1234 descriptionNEW new5678
1234 descriptionFUTURE future1234
1234 descriptionFUTURE future5678
...
So far i have tried:
df=pd.DataFrame(data)
df['type']=''
df['description']=''
for id, row in df.iterrows():
df['type'][id]='descriptionOLD'
df['description'][id]=row['descriptionOLD']
df.pop('descriptionOLD')
df.pop('descriptionNEW')
df.pop('descriptionFUTURE')
and it gets me this result:
product type description
0 1234 descriptionOLD old1234
1 5678 descriptionOLD old5678
but i don't know how to handle the new and future descriptions as well to achieve the desired dataframe.