I am new to Python and am trying a simple calculation. I have a data frame with 1000 observations for different years and want to calculate the mean of a variable by year. I've used the "groupby" statement, but the resulting means only occur once per year. How can I have repeating mean values for all 1000 observations in the original dataset? Is there a way to do this without merging grouped results to the original data frame?
Edit: using data from this link as an example, if I have the following:
Is there a way to calculate this mean in the original data and have it for every row?