合并 pandas 中的两个时间序列

编程入门 行业动态 更新时间:2024-10-28 22:24:43
本文介绍了合并 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 中的两个时间序列

本文发布于:2023-10-24 18:09:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1524635.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:序列   两个   时间   pandas

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!