Skip to content
Advertisement

ValueError: Invalid fill method. Expecting pad (ffill) or backfill (bfill). Got nearest

I have this df:

JavaScript

And when I try to run this interpolation: pmms_df.interpolate(method = 'nearest', inplace = True)

I get ValueError: Invalid fill method. Expecting pad (ffill) or backfill (bfill). Got nearest

I read in this post that pandas interpolate doesn’t do well with the time columns, so I tried this: pmms_df[['U.S. 30 yr FRM', 'U.S. 15 yr FRM']].interpolate(method = 'nearest', inplace = True)

but the output is exactly the same as before the interpolation.

Advertisement

Answer

It may not work great with date columns, but it works well with a datetime index, which is probably what you should be using here:

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