繁体   English   中英

如何对两个 dataframe 中的一行求和,该行在 Pandas Dataframe 中具有相同的值

[英]How to sum a row from two dataframe that has the row with certain same value in Pandas Dataframe

预期 output 是 dataframe:

日期 总收入
2019-11-01 59946202
2019-11-02 95429717
2019-11-03 89662309
... ...
2020-03-31 6687349

Dataframe 1:

在此处输入图像描述

Dataframe 2:

在此处输入图像描述

将日期更改为 DataFrame 的“索引”,它将自动执行数据 alignment 的算术计算。

合并不同的 dataframe ,然后根据需要使用 concat function。 https://pandas.pydata.org/docs/user_guide/merging.html 示例帧 = [df1, df2] 结果 = pd.concat(Frames)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM