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?
pandas.DataFrame.fillna
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With