Reputation: 271
I would like to ask if we could merge rows from multiple columns, i.e.
Following answers from @Dimitris Thomas, I would be able to obtain the following
And wondering how the code could be updated to get:
Thanks
Upvotes: 5
Views: 1795
Reputation: 24314
IIUC:
Firstly:
df=pd.read_excel('filename.xlsx')
#read excel file in pandas
try via set_index()
and to_excel()
df.set_index(df.columns[:-1].tolist()).to_excel('filename.xlsx',header=None)
#OR(Since you don't provide data as text so not sure which one should work)
df.set_index(df.columns.tolist()).to_excel('filename.xlsx',header=None)
Upvotes: 6