跟进这个问题 https://stackoverflow.com/questions/61217923/merge-rows-based-on-value-pandas-to-excel-xlsxwriter/61228294?noredirect=1#comment120527781_61228294
我想问我们是否可以合并多列中的行,即
根据 @Dimitris Thomas 的回答,我将能够获得以下内容
并想知道如何更新代码以获得:
Thanks
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)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)