BUG: pd.Series.interpolate non-numeric index column (21662) by TrigonaMinima · Pull Request #25394 · pandas-dev/pandas (original) (raw)

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation29 Commits1 Checks0 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

TrigonaMinima

mroeschke

mroeschke

mroeschke

"setting a numeric index column before "\
"interpolating."
with pytest.raises(ValueError, match=expected_error):
result = df[0].interpolate(method="zero")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can parameterize over method

mroeschke

@pep8speaks

Hello @TrigonaMinima! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2019-03-24 19:04:39 UTC

@codecov

@codecov

mroeschke

jreback

"method",
{
"linear", "zero", "slinear", "quadratic", "cubic", "spline",
"barycentric", "polynomial", "krogh", "piecewise_polynomial",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we might have a fixture for this

TrigonaMinima

@TrigonaMinima

@jreback this PR is complete. I have rebased it with the master as well. The unsuccessful checks are because of the previous commits.

@jreback

jreback

@@ -6863,6 +6863,18 @@ def interpolate(self, method='linear', axis=0, limit=None, inplace=False,
index = np.arange(len(_maybe_transposed_self._get_axis(alt_ax)))
else:
index = _maybe_transposed_self._get_axis(alt_ax)
methods = {"index", "values", "nearest", "time"}
num_dt_flg = (

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

call is this: is_numeric_or_datetime

@@ -14,6 +14,8 @@
from pandas.errors import PerformanceWarning
import pandas.util._test_decorators as td
from pandas.core.dtypes.common import is_timedelta64_dtype

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in tests we want to import from: pandas.api.types

if method == "pchip":
_skip_if_no_pchip()
elif is_timedelta64_dtype(ind):
if method in {"linear", "index", "values", "pchip"}:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i find this a touch complicated. it might be worthile to make this into several tests (you would make a fixture for the input parameterization)

@jreback

can you add a whatsnew note as well (bug fixes / numeric)

@TrigonaMinima

jreback

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good. small change. ping on green.

"Index column must be numeric or datetime type when "
"using any interpolation method other than linear. "
"Try setting a numeric or datetome index column before "
"interpolating.")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can add that {method} was passed in the text.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use a replacement, e.g. "{method}"....format(method=method)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@TrigonaMinima

jreback

"Index column must be numeric or datetime type when "
"using any interpolation method other than linear. "
"Try setting a numeric or datetome index column before "
"interpolating.")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use a replacement, e.g. "{method}"....format(method=method)

jreback

@jreback