### Pandas Time series: Efficient operation on daily data

Generating the data random.seed(42) date_rng = pd.date_range(start=’1/1/2018′, end=’1/08/2018′, freq=’H’) df = pd.DataFrame(np.random.randint(0,10,size=(len(date_rng), 3)), columns=[‘data1’, ‘data2’, ‘data3’], index= date_rng) daily_mean_df = pd.DataFrame(np.zeros([len(date_rng), 3]), columns=[‘data1’, ‘data2’, ‘data3’], index= date_rng) mask = np.random.choice([1, 0], df.shape, p=[.35, .65]).astype(bool) df[mask] = np.nan # Data column to calculate each day day = [[‘data1’, ‘data2’], [‘data1’, ‘data2’], [‘data2’, ‘data3’], [‘data1’, ‘data3’], [‘data2’,…

Details