利用 pandas 自动合并 excel 单元格
代码比较简洁
df = pd.DataFrame({
"animal": ("horse", "horse", "dog", "dog"),
"color": ("black", "white", "grey", "black"),
"name": ("Blacky", "Wendy", "Rufus", "Catchy")
})
index = df.columns.to_list()
df = df.set_index(index)
df.to_excel("demo.xlsx")
效果展示
本文来自博客园,作者:vx_guanchaoguo0,转载请注明原文链接:https://www.cnblogs.com/guanchaoguo/p/17772943.html