python-3.x - 用python计算excel列中的元素
问题描述
我正在学习python。我有一个 excel 文档,其中一个第一列包含多个元素(第 1 列包含“a”和“b”),第二列包含第 1 列中元素的值:
Column 1 Column 2
a 10
a 100
b 1
b 15
b 10
我正在尝试在 Python 3 中编写一个脚本,其中我得到以下内容:
Column 1 Column 2
a 110 --> Sum of all elements in previous column 1 for a
b 26 --> Sum of all elements in previous column 1 for b
有什么建议么?谢谢。
我已经尝试过使用列表和字典,但没有得到合理的答案。
Column 1 Column 2
a 110 --> Sum of all elements in previous column 1 for a
b 26 --> Sum of all elements in previous column 1 for b
from xlwt import Workbook
i=0
for element in Column_1:
sheet1.write(i,0,element)
i +=1
解决方案
推荐阅读
- amqp - 如何使用 rhea 使用 amqp 在 azure 服务总线中实现重新交付延迟
- css - Kendo MVC 电子表格 - 将单元格文本旋转 90°
- css - HTML 表单上的 Wordpress Divi 自定义 CSS
- docker - Docker 中的 InfluxDB 无法移动数据量
- eclipse - 将源码添加到Eclipse中Tomcat9 Targeted Runtime的所有jar中,以便F3打开源码
- neural-network - Torchtext AttributeError:“示例”对象没有属性“text_content”
- java - 使用 Fast Purge Open API 通过 java 代码清除 akamai 中的缓存 URL
- python - python“IndexError:索引 8 超出轴 0 的范围,大小为 8”
- visual-studio-code - 在 VSCode 的终端中,空格太多
- pipenv - pipenv:pipenv 如何计算 pipfile.lock 已过期