Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user

How to add a calculated column in a pandasPandas dataframe?

I am new to pythonPython/pandasPandas so I'm struggling a bit here. I

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éJosé   pm25    20  13.0  53.0   25.0  1232.00
1  2020-04-04      CR   San JoséJosé   pm25    23  17.0  57.0   38.0  1302.57
2  2020-04-24      CR   San JoséJosé   pm25    23  30.0  80.0   59.0  1966.13
3  2020-01-14      CR   San JoséJosé   pm25    24  13.0  34.0   21.0   379.55
4  2020-02-07      CR   San JoséJosé   pm25    23  57.0  95.0   72.0   838.97

Does anybody have an idea as to how I can proceed?

Thank you

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?

Thank you

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?

Source Link
Ghazal
  • 13
  • 2
  • 3

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?

Thank you