I am definitely a novice at Python. I have a pandas data frame with an 'Hour' column that has values 0-23 for each hour of the day, 'Day' column for each day of the year. I want to break this down so that I have a 'Month' column 1-12, that agglomerates the days accordingly, and then within each month, I want to take the average of all matching Hours from a different column 'Var from mean'.
Here is a sample of the data frame
So I want two new columns, 'Month' and 'Var_avg'. 'Month' would have twelve values, 1-12, where days 1-31 would have value 1 in 'Month', days 1-28 would have value 2 in 'Month', etc. And then there will be 31 instances of 'Hour'=0 in 'Month'=1. For those rows that have matching 'Hour' within each month, I want to take the average of the column 'Variance from mean' and put that value in a new column 'Var_avg' that would be the same for all rows where 'Hour'=0 and 'Month'=1, etc. I've tried splitting the data frame into the 12 months, but then I get a list with twelve different callable data frames, and then I would need to do groupby.mean but tell it to take avg of 'Variance by mean' not 'Day', which it seems to want to do...
Thanks!