excel - How can I add previous column values to to get new value in Excel?
问题描述
I am working on graph and in need data in below format. I have data in COL A
. I need to calculate COL B
values as in below picture.
What is the formula for obtaining this in excel?
解决方案
您可以使用cumsum
and shift
:
# sample data
df = pd.DataFrame({'COL A': np.arange(11)})
df['COL B'] = df['COL A'].shift(fill_value=0).cumsum()
输出:
COL A COL B
0 0 0
1 1 0
2 2 1
3 3 3
4 4 6
5 5 10
6 6 15
7 7 21
8 8 28
9 9 36
10 10 45
推荐阅读
- java - 为什么我的应用会发出 Unsupported URI content 错误?
- javascript - ajax调用后如何触发脚本
- flutter - 使用 NetworkImage 显示来自 Google Drive 的图像
- vba - 将单词“and”添加到消息框中的列表中
- pandas - 数字是csv中的字符串?
- python - 如何将两列(第一列具有相同的值)插入数据框
- optaplanner - 尝试本地搜索时出现 JBoss 工作台异常
- python - 如何更有效地在 Python 中压缩 jpeg?
- laravel - 在前端使用 API 时如何处理 x-amzn-remapped-authorization?
- python - 在python中,带有所有元素的切片和它本身有什么区别?