在我看来,这听起来像是应该在本地完成的事情,但我只是无法在 Pandas 中找到执行此操作的函数(是的,我可能只是一个白痴)。
基本上,我们假设我有:
df1 =
x y date
--------------------
1 2 1/1/2020
2 3 2/1/2020
3 4 3/1/2020
4 5 4/1/2020
df2 =
x y date
--------------------
3 4 1/1/2020
4 5 2/1/2020
5 6 3/1/2020
6 7 4/1/2020
df3 =
x y date
--------------------
5 6 1/1/2020
6 7 2/1/2020
7 8 3/1/2020
8 9 4/1/2020
由此产生的 df 应为:
df_result =
x y date
--------------------
9 12 1/1/2020
12 15 2/1/2020
15 18 3/1/2020
18 21 4/1/2020
Use concat http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.concat.html与骨料sum
:
df = pd.concat([df1, df2, df3]).groupby('date', as_index=False).sum()
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)