I am working on a code that first reads minute data from a csv file then averages it hourly. Then it averages the values for the entire month in columns 1-10 from 12:00am - 3:00am. I would like to then take those 10 averages and subtract them from each value in columns 1-10.
import pandas as pd
import numpy as np
df = pd.read_csv("datafile.csv", index_col="DateTime", parse_dates=True)
df = df.resample('1H').mean()
df = df.reindex(pd.date_range(df.index.min(), df.index.max(), freq="1H"))
df.ix[:,1:10].between_time('0:00', '3:00').resample('1M').mean()
the last line of this code gives me the monthly average of each columns data from 12am-3am. I would like to subtract those 10 averages from all of the values in each of those 10 columns. So for example if the monthly average of column 1 is 3.5 I would like to subtract 3.5 from each value in column 1 (and repeated for all 10 columns).