Relative Content

Tag Archive for pythondataframegroup-byaggregatepython-polars

Python-Polars: How to fill NAs with the average of the two values between?

I have a polars data frame with different weather stations and their data. The end goal is a time series analysis. However, some of the temperature values are blank. For it to not mess with the model I want to be able to fill in the blanks with the average of the two days on either side of it. I would like to group_by() weather station somehow in the process as to not take one stations information and use it for another stations missing day average. If there is only one value (Beginning or End of the time frame) then I want to use the same number as the day next to it.