I have a data-frame of stock features and price, with 26 columns in name df_prc_RI3.( like image) enter image description here
I want to convert it to multi index columns with level[ stack name].
col = pd.MultiIndex.from_product([ ['stack name'],df_prc_RI3.columns])
ddf = pd.DataFrame(df_prc_RI3, columns=col)
But my problem is that… values of rows disappear … and they convert to Nan, after converting, like photo !!!. enter image description here
CodePudding user response:
Use:
df_prc_RI3.columns = pd.MultiIndex.from_product([ ['stack name'],df_prc_RI3.columns])
print (df_prc_RI3)