-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
Description
Is your feature request related to a problem?
When trying to interpolate a column with dtype integer with method="linear" the error message is not very descriptive (example to reproduce at the bottom of this issue):
ValueError: Invalid fill method. Expecting pad (ffill) or backfill (bfill). Got linear
As "linear" is the default interpolation method I think the error message should be more descriptive, even though IntegerArray is still experimental according to the docs.
Describe the solution you'd like
I think the error message should include a hint to the potential cause that the array you're trying to interpolate is of dtype integer. Something like this could work:
ValueError: Invalid fill method. Expecting pad (ffill) or backfill (bfill). Got linear. Are you trying to interpolate an integer column?
I would be happy to create a PR with the improvement myself.
API breaking implications
As this only requires a change to the error message it does not break any API.
Describe alternatives you've considered
An alternative solution would be to implement linear interpolation for integer arrays but I suspect that that is not compatible/unexpected with some use-cases of integer arrays.
Additional context
Reproducable example:
import pandas as pd
s = pd.Series([1, None, 3], dtype=pd.Int64Dtype())
s.interpolate(method="linear")