'completing missing data on period imput value based on next month in python jupyter notebook

I am working on a DF containing sales by category between 2021 and 2023. I got 3 category and the 1 contributing a lot on the revenu. Problem is, In the month of Sept 2021, I have no sales for the category 1. I have no information on stock, i think it is probably an error in the data collection. I would like to replace those missing data using the same value as the next month, anyone has any idea how to do this on python/ jupyter notebook?

Thanks a lot for your attention Nice day to all missing data evolution graph

Code :

df_months = cat1.groupby(pd.Grouper(key='date', freq='M')).sum().reset_index()

df_months['sale_ke'] = df_months.price / 1000
df_months = df_months[['date', 'sale_ke']]
print(df_months)
print("----")
print('Le CA moyen mensuel est de', round(df_months.sale_ke.mean()), 'K euros')
print("----")
print("Le mois d'octobre 2021 est le seul dont le CA est bien en dessous de la moyenne")

         date  sale_ke
0  2021-03-31   186.97
1  2021-04-30   156.14
2  2021-05-31   165.89
3  2021-06-30   189.16
4  2021-07-31   188.52
5  2021-08-31   162.99
6  2021-09-30   190.61
7  2021-10-31    33.76
8  2021-11-30   252.91
9  2021-12-31   251.03
10 2022-01-31   256.27
11 2022-02-28   213.12
12 2022-03-31   206.49
13 2022-04-30   195.26
14 2022-05-31   205.53
15 2022-06-30   201.91
16 2022-07-31   193.97
17 2022-08-31   211.36
18 2022-09-30   195.38
19 2022-10-31   199.61
20 2022-11-30   200.43
21 2022-12-31   205.95
22 2023-01-31   210.10
23 2023-02-28   180.35


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source