I have a times series with temperature and radiation in a pandas dataframe
. The time resolution is 1 minute in regular steps.
import datetime
import pandas as pd
import numpy as np
date_times = pd.date_range(datetime.datetime(2012, 4, 5, 8, 0),
datetime.datetime(2012, 4, 5, 12, 0),
freq='1min')
tamb = np.random.sample(date_times.size) * 10.0
radiation = np.random.sample(date_times.size) * 10.0
frame = pd.DataFrame(data={'tamb': tamb, 'radiation': radiation},
index=date_times)
frame
<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 241 entries, 2012-04-05 08:00:00 to 2012-04-05 12:00:00
Freq: T
Data columns:
radiation 241 non-null values
tamb 241 non-null values
dtypes: float64(2)
How can I down-sample this dataframe
to a resolution of one hour, computing the hourly mean for the temperature and the hourly sum for radiation?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…