我有两个Pandas系列(pandas.core.series.Series
),我想把它们合并成一个系列,在公共键上添加如下值:
series1:
AAA Championship Car season 1
Act of Parliament of Ontario 1
Act of Parliament of the United Kingdom 18
Act of Parliament of the United Kingdom election law 1
+
series2:
ATP Buenos Aires 1
ATP World Tour Finals 1
Act of Parliament of British Columbia 1
Act of Parliament of the United Kingdom 18
Act of Parliament of the United Kingdom election law 1
=
series3:
AAA Championship Car season 1
ATP Buenos Aires 1
ATP World Tour Finals 1
Act of Parliament of British Columbia 1
Act of Parliament of Ontario 1
Act of Parliament of the United Kingdom 36
Act of Parliament of the United Kingdom election law 2
让我们试试
pd.concat
和sum
:输出:
您可以使用
pandas.Series.sum()
https://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.add.html 这也提供了一种填充缺失值的方法。你知道吗例如,您的代码可以是
相关问题 更多 >
编程相关推荐