-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: fix non-existent variable in NDFrame.interpolate #29142
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 and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
NDFrame.interpolate fails if axis is specified by name and not integer
pandas/core/generic.py
Outdated
if axis == 0: | ||
ax = self._info_axis_name | ||
_maybe_transposed_self = self | ||
elif axis == 1: | ||
_maybe_transposed_self = self.T | ||
ax = 1 | ||
else: | ||
ax = axis |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is impossible to get here; L734-736 can just be deleted
Can you add a test for the bug this fixes |
Added test_interpolate_axis_argument() to TestNDFrame
Absolutely! I added a test in the test_generic.TestNDFrame, is that reasonable? |
pandas/tests/generic/test_generic.py
Outdated
@@ -948,3 +948,7 @@ def test_deprecated_get_dtype_counts(self): | |||
df = DataFrame([1]) | |||
with tm.assert_produces_warning(FutureWarning): | |||
df.get_dtype_counts() | |||
|
|||
@pytest.mark.parametrize("axis", [0, 1, "index", "columns", "rows"]) | |||
def test_interpolate_axis_argument(self, axis): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reference issue number above this line as a comment.
doc/source/whatsnew/v1.0.0.rst
Outdated
@@ -249,6 +249,7 @@ Bug fixes | |||
~~~~~~~~~ | |||
|
|||
- Bug in :meth:`DataFrame.to_html` when using ``formatters=<list>`` and ``max_cols`` together. (:issue:`25955`) | |||
- Bug in :func:`pandas.core.generic.NDFrame.interpolate` where specifying axis by name references variable before it is assigned (:issue:`29132`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are user facing, so we shouldn't reference NDFrame. Instead, refer to just :meth:`DataFrame.interpolate`, even if it affects Series as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm outside of @jreback comments
pandas/tests/frame/test_missing.py
Outdated
@@ -872,10 +873,22 @@ def test_interp_rowwise(self): | |||
result = df.interpolate(axis=1, method="values") | |||
assert_frame_equal(result, expected) | |||
|
|||
# GH 29142: test axis names |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rather than adding tests like this, can you create a new test function and paramterize on the axis
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a new parametrized function in the latest commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pytest is returning with an uncaught warning in the same file from a call to df.median(). Should I add tm.assert_produces_warning()
?
pandas/tests/frame/test_missing.py::TestDataFrameMissingData::test_fillna_categorical_nan
python3.7/site-packages/numpy/lib/nanfunctions.py:1115: RuntimeWarning: All-NaN slice encountered
overwrite_input=overwrite_input)
Also moved whatsnew comments
RuntimeWarning occurs due to a call to df.median (np.nanmedian)
thanks @ellequelle |
👍 |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff