在熊猫中合并两个时间序列

use*_*844 10 python time-series pandas

如果在某处明显记录了这一点,我会道歉,但我发现它时遇到了麻烦.我有两个TimeSeries,有一些重叠的日期/索引,我想合并它们.我假设我必须指定两个系列中的哪一个从重叠日期中取出值.为了说明,我有:

s1:
2008-09-15    100
2008-10-15    101

s2:
2008-10-15    101.01
2008-11-15    102.02
Run Code Online (Sandbox Code Playgroud)

而且我要:

s3:
2008-09-15    100
2008-10-15    101
2008-11-15    102.02
Run Code Online (Sandbox Code Playgroud)

要么

s3:
2008-09-15    100
2008-10-15    101.01
2008-11-15    102.02
Run Code Online (Sandbox Code Playgroud)

use*_*844 14

这可以通过以下方式实现combine_first:

In [11]: s1.combine_first(s2)
Out[11]:
2008-09-15    100.00
2008-10-15    101.00
2008-11-15    102.02
dtype: float64
Run Code Online (Sandbox Code Playgroud)