df['ffill'] = df.asfreq('M', method='ffill')
Here is what the above code is Doing:
1. We’re creating a new column called ‘ffill’ in our DataFrame.
2. We’re using the asfreq() method to change the frequency of our DataFrame to monthly (‘M’).
3. We’re using the method=’ffill’ argument to tell Pandas to fill in the missing values using the last known value.