Combine two daily series into one hour series

I have two daily series and I have to combine them into one watch series with the first series for the first 12 hours and the second series for the remaining hours.

Is there a more efficient way instead of creating the list manually and converting it to a row? thank

a = pd.Series(np.random.rand(5), pd.date_range('2015-01-01', periods=5))
b = pd.Series(np.random.rand(5), pd.date_range('2015-01-01', periods=5))
c = an hourly series

      

+3


source to share


1 answer


possibly:

>>> b.index += dt.timedelta(hours=12)
>>> pd.concat((a, b), axis=0).sort_index()
2015-01-01 00:00:00    0.150
2015-01-01 12:00:00    0.970
2015-01-02 00:00:00    0.746
2015-01-02 12:00:00    0.937
2015-01-03 00:00:00    0.523
2015-01-03 12:00:00    0.392
2015-01-04 00:00:00    0.606
2015-01-04 12:00:00    0.459
2015-01-05 00:00:00    0.221
2015-01-05 12:00:00    0.029
dtype: float64

      



and ts.asfreq('H', method='ffill')

to have an hourly frequency.

+1


source







All Articles