Reputation: 4571
In fillna
, the arguments method='pad'
and method='ffill'
appear to give the same behavior. Is there any difference? Is one method preferable to the other?
Upvotes: 4
Views: 7151
Reputation: 294338
They are the same. I like 'ffill'
because it's more descriptive of what it does.
We can see in the source for the generic NDFRame.fillna
source
method = missing.clean_fill_method(method)
Where we can see that when method == 'ffill'
it gets swapped for 'pad'
source
if method == 'ffill':
method = 'pad'
Note
pandas also has a ffill
method that does the same thing
Upvotes: 11