看了一点资料,勉强算是能解决问题了,
这个行代码
df.to_excel(outputpath,index=False, header=False)
如果变成
df.to_excel(outputpath,sep='\t',,index=False, header=False)
会报错
to_excel() got an unexpected keyword argument about “sep”
去掉这个参数后运行正常
以下为自己的代码仅供参考(需要安装相关库)
ser1 = pd.Series(topics)
ser2 = pd.Series(replies)
ser3 = pd.Series(postdates)
df = pd.DataFrame({'col1': ser1, 'col2': ser2, 'col3': ser3})
df.sort_values('col3')
print(df)
outputpath = 'c:/Users/NGA.xlsx'
df.to_excel(outputpath,index=False, header=False)