小编pra*_*kar的帖子

How to merge two pandas time series objects with different date time indices?

I have two disjoint time series objects, for example

-ts1

 Date           Price
 2010-01-01     1800.0
 2010-01-04     1500.0
 2010-01-08     1600.0
 2010-01-09     1400.0
 Name: Price, dtype: float64
Run Code Online (Sandbox Code Playgroud)

-ts2

 Date           Price
 2010-01-02     2000.0
 2010-01-03     2200.0
 2010-01-05     2010.0
 2010-01-07     2100.0
 2010-01-10     2110.0
Run Code Online (Sandbox Code Playgroud)

How I could merge the two into a single time series that should be sorted on date? like

-ts3

 Date           Price
 2010-01-01     1800.0
 2010-01-02     2000.0
 2010-01-03     2200.0
 2010-01-04     1500.0
 2010-01-05     2010.0
 2010-01-07     2100.0
 2010-01-08     1600.0
 2010-01-09     1400.0
 2010-01-10     2110.0
Run Code Online (Sandbox Code Playgroud)

python pandas

6
推荐指数
1
解决办法
2062
查看次数

标签 统计

pandas ×1

python ×1