I would like to calculate a moving average in Pandas. Instead of specifying the number of observations, I would like to specify the number of days. The number of observations varies every day.
Example input:
+--------+------------+------------+
| TICKER | DATE | RATING |
+--------+------------+------------+
| AAPL | 05.10.2020 | 0.24080577 |
+--------+------------+------------+
| AAPL | 05.10.2020 | 0.11473013 |
+--------+------------+------------+
| AAPL | 05.10.2020 | 0.7327437 |
+--------+------------+------------+
| AAPL | 06.10.2020 | 0.49492914 |
+--------+------------+------------+
| AAPL | 06.10.2020 | 0.83926228 |
+--------+------------+------------+
| AAPL | 07.10.2020 | 0.18731226 |
+--------+------------+------------+
| AAPL | 07.10.2020 | 0.12772092 |
+--------+------------+------------+
| AAPL | 07.10.2020 | 0.8952811 |
+--------+------------+------------+
Example output:
+--------+------------+------------+
| TICKER | DATE | RATING |
+--------+------------+------------+
| AAPL | 05.10.2020 | 0.36275986 |
+--------+------------+------------+
| AAPL | 06.10.2020 | 0.4844942 |
+--------+------------+------------+
| AAPL | 07.10.2020 | 0.45409816 |
+--------+------------+------------+
In addition to a simple moving average I would like to use the exponentially weighted average: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.ewm.html