I am having a data frame with hourly power data. I want to compute daily energy.
My code:
df = pd.DataFrame({'power':np.arange(1.0,9.0)},index=pd.date_range(start='2020-05-04 08:00:00', freq='1h', periods=8))
df['energy'] = xdf['power'].resample('1D').sum()
Present output:
df =
power energy
2020-05-04 08:00:00 1.0 NaN
2020-05-04 09:00:00 2.0 NaN
2020-05-04 10:00:00 3.0 NaN
2020-05-04 11:00:00 4.0 NaN
2020-05-04 12:00:00 5.0 NaN
2020-05-04 13:00:00 6.0 NaN
2020-05-04 14:00:00 7.0 NaN
2020-05-04 15:00:00 8.0 NaN
There is something wrong in my calculations and I see NaN only? How to compute the daily energy? Is it just summing the power? do we need to multiply time and how do we do it?