<p>我想你需要先<a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.shift.html" rel="nofollow noreferrer">^{<cd1>}</a>一个小时,然后<a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.resample.html" rel="nofollow noreferrer">^{<cd2>}</a>在^{<cd3>之前:</p>
<pre><code>print (offpeak_hist.shift(-1, freq='H'))
Maximum Demand (KVA) Consumption (KVAh) Power Factor
Timestamp
2017-04-01 00:00:00 127.0 261.0 0.81
2017-04-01 01:00:00 133.0 268.0 0.79
2017-04-01 02:00:00 119.0 273.0 0.92
2017-04-01 03:00:00 118.0 263.0 0.78
2017-04-01 04:00:00 135.0 271.0 0.86
2017-04-01 05:00:00 130.0 257.0 0.82
2017-04-01 22:00:00 120.0 261.0 0.78
2017-04-01 23:00:00 121.0 272.0 0.83
2017-04-02 00:00:00 126.0 263.0 0.90
2017-04-02 01:00:00 132.0 266.0 0.83
2017-04-02 02:00:00 132.0 275.0 0.90
2017-04-02 03:00:00 122.0 259.0 0.77
2017-04-02 04:00:00 119.0 271.0 0.78
2017-04-02 05:00:00 122.0 259.0 0.81
2017-04-02 22:00:00 115.0 264.0 0.87
2017-04-02 23:00:00 129.0 273.0 0.86
df = offpeak_hist.shift(-1, freq='H').resample('D').sum().dropna()
print (df)
Maximum Demand (KVA) Consumption (KVAh) Power Factor
Timestamp
2017-04-01 1003.0 2126.0 6.59
2017-04-02 997.0 2130.0 6.72
</code></pre>