Skip to content
Advertisement

Pandas method to back extend a time series by repeating the first value

Is there a method to extend a pandas time series into the past repeating the first value found in the serie?. For example:

JavaScript

And I want an extended series

JavaScript

I’m asking if exists a direct method.

Advertisement

Answer

Let’s try reindex and bfill or use fill_value argument of reindex as mozway kindly pointing out.

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement