python - 我们可以将行和列> 1的数据框复制到Excel工作表中吗?
问题描述
这是我正在使用的代码
excel = win32com.client.Dispatch('Excel.Application')
wb = excel.Workbooks.Open('myWorkbook.xlsx')
df = pd.DataFrame({'A':[1,2,3,4,5], 'B':[11,22,33,44,55], 'C':['a','b','c','d','e']})
wb.Sheets('Template').Copy(Before=None, After=wb.Sheets(wb.Sheets.count))
ws = wb.Sheets(wb.Sheets.count)
ws.Range(ws.cells(40,19), 40+len(df.index)-1, 19+len(df.columns)).Value = df.values
但我总是收到以下错误: ValueError: ndarray is not C-contiguous
解决方案
推荐阅读
- scala - 使用 Spark Scala 和 Sbt 设置 IntelliJ
- python - RuntimeError: invalid argument 1:cannot perform reduction function max on tensor without element because the operation does not have an identity
- c# - 一行代码没有带 3 个参数的构造函数?
- excel - 为什么 Match("text", A:A) 函数不适用于 Excel 中的文本
- java - Hibernate @ManyToMany 有额外的列
- graphql - Graphene-Django:如何在不实际引发错误的情况下从中间件附加错误
- r - 从数据框中查找向量的位置
- python - python命令行参数
- python - tf.image.decode_jpeg 经常需要永远加载文件
- kubernetes-dashboard - 恢复 kubernetes-dashboard pod?