Skip to content
Advertisement

Calculate rolling average for all columns pandas

I have the below dataframe:

JavaScript

I want to replace the NaN values with the 3 month rolling average. How should I got about this?

Advertisement

Answer

If you take NaNs as 0 into your means, can do:

JavaScript

This will give you:

JavaScript
Advertisement