【发布时间】:2021-05-18 18:18:21
【问题描述】:
我正在将字典中的数据写入到如下所示的 excel 中
my_dict = { 'one': 100, 'two': 200, 'three': 300}
df = pd.DataFrame(my_dict.items(), columns=['Summary','Count'])
with pd.ExcelWriter('outfile.xlsx') as writer:
df.to_excel(writer, sheet_name='sheet1', index=False)
对于上面的代码,我得到了想要的输出,如下所示。
我还有一个列表,其中有一些值需要粘贴到 excel 的第三列。
my_list = [10,20,30]
预期输出:
编辑:我需要同时在 my_dict 和 my_list 中添加数据。
我已尝试找出解决方案,但遗憾的是无法找到。任何帮助表示赞赏! 非常感谢!!
【问题讨论】:
标签: python python-3.x pandas pyexcel