2021年3月5日星期五

Filling In Empty Dates With Previous Data in Pandas

So I have the current file in Excel where I have dates and don't have dates for everything which can be seen.

enter image description here

I read this excel file into a pandas dataframe, rename the column and get the following:

enter image description here

My question is, how would I get it so every empty date in the dataframe is filled in with the last previous date encountered. All of the blanks between 04/03/2021 and 05/03/2021 gets replaced with 04/03/2021, so every row in my dataframe has a date associated with it?

Thanks!

https://stackoverflow.com/questions/66501368/filling-in-empty-dates-with-previous-data-in-pandas March 06, 2021 at 09:00AM

没有评论:

发表评论