本文介绍了合并 pandas 中的两个时间序列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
很抱歉,如果这确实记录在某处,但我很难找到它.我有两个带有一些重叠的日期/索引的TimeSeries,我想将它们合并.我假设必须指定两个系列中的哪个系列来获取重叠日期的值.为了说明,我有:
Apologies if this is obviously documented somewhere, but I'm having trouble discovering it. I have two TimeSeries with some overlapping dates/indices and I'd like to merge them. I assume I'll have to specify which of the two series to take the values from for the overlapping dates. For illustration I have:
s1: 2008-09-15 100 2008-10-15 101 s2: 2008-10-15 101.01 2008-11-15 102.02我想要:
s3: 2008-09-15 100 2008-10-15 101 2008-11-15 102.02或
s3: 2008-09-15 100 2008-10-15 101.01 2008-11-15 102.02推荐答案
可以使用 combine_first :
In [11]: s1bine_first(s2) Out[11]: 2008-09-15 100.00 2008-10-15 101.00 2008-11-15 102.02 dtype: float64更多推荐
合并 pandas 中的两个时间序列
发布评论