我试图将时间段的总和均匀地分配给较高采样时间段的分量.
我做了什么:
>>> rng = pandas.PeriodIndex(start='2014-01-01', periods=2, freq='W')
>>> ts = pandas.Series([i+1 for i in range(len(rng))], index=rng)
>>> ts
2013-12-30/2014-01-05 1
2014-01-06/2014-01-12 2
Freq: W-SUN, dtype: float64
>>> ts.resample('D')
2013-12-30 1
2013-12-31 NaN
2014-01-01 NaN
2014-01-02 NaN
2014-01-03 NaN
2014-01-04 NaN
2014-01-05 NaN
2014-01-06 2
2014-01-07 NaN
2014-01-08 NaN
2014-01-09 NaN
2014-01-10 NaN
2014-01-11 NaN
2014-01-12 NaN
Freq: D, dtype: float64
Run Code Online (Sandbox Code Playgroud)
我真正想要的是:
>>> ts.resample('D', some_miracle_thing)
2013-12-30 1/7
2013-12-31 1/7
2014-01-01 1/7
2014-01-02 1/7
2014-01-03 1/7
2014-01-04 1/7
2014-01-05 1/7
2014-01-06 …
Run Code Online (Sandbox Code Playgroud)