How to add a calculated column in a Pandas dataframe? I am new to Python/Pandas so I'm struggling a bit here.  

I have a dataframe with air quality data from 2016 to 2020. I want to calculate the annual rate of change for each measured value to compare them with the value the year before at the same day and month.

These are the first lines of the dataframe.

         Date Country       City Specie count   min   max median variance
0  2020-02-23      CR   San José   pm25    20  13.0  53.0   25.0  1232.00
1  2020-04-04      CR   San José   pm25    23  17.0  57.0   38.0  1302.57
2  2020-04-24      CR   San José   pm25    23  30.0  80.0   59.0  1966.13
3  2020-01-14      CR   San José   pm25    24  13.0  34.0   21.0   379.55
4  2020-02-07      CR   San José   pm25    23  57.0  95.0   72.0   838.97


Does anybody have an idea as to how I can proceed?
Try:
# Toy dataset:
air = pd.DataFrame({&quot;Date&quot;:[&quot;2020-02-23&quot;,&quot;2020-04-04&quot;,&quot;2020-04-24&quot;,&quot;2020-01-14&quot;,&quot;2020-02-07&quot;],
&quot;Country&quot;:[&quot;CR&quot;,&quot;CR&quot;,&quot;CR&quot;,&quot;CR&quot;,&quot;CR&quot;],
&quot;count&quot;:[20,23,23,24,23],
&quot;max&quot;:[13.0,17.0,30.0,13.0,57.0 ],
&quot;min&quot;:[20,23,23,24,23],
&quot;median&quot;:[53.0,57.0,80.0,34.0,95.0]})

Input:

# Index column needs to be a datetime so
air[&quot;Date&quot;] = pd.to_datetime(air[&quot;Date&quot;])

# Group by year
air.set_index(&quot;Date&quot;).groupby(pd.Grouper(freq = &quot;y&quot;))[[&quot;count&quot;,&quot;min&quot;,&quot;max&quot;]].diff()

Output: