Skip to content

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

Merged
merged 11 commits into from
Oct 25, 2019

Conversation

ellequelle
Copy link
Contributor

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
Copy link
Member

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

@jbrockmendel
Copy link
Member

Can you add a test for the bug this fixes

Added test_interpolate_axis_argument() to TestNDFrame
@ellequelle
Copy link
Contributor Author

Can you add a test for the bug this fixes

Absolutely! I added a test in the test_generic.TestNDFrame, is that reasonable?

@gfyoung gfyoung added the Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate label Oct 22, 2019
@@ -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):
Copy link
Member

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.

@@ -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`)
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see!

@jreback jreback added this to the 1.0 milestone Oct 23, 2019
@jreback jreback added the Bug label Oct 23, 2019
Copy link
Member

@WillAyd WillAyd left a 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

@@ -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
Copy link
Contributor

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

Copy link
Contributor Author

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

Copy link
Contributor Author

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)

RuntimeWarning occurs due to a call to df.median (np.nanmedian)
@jreback jreback merged commit c983d52 into pandas-dev:master Oct 25, 2019
@jreback
Copy link
Contributor

jreback commented Oct 25, 2019

thanks @ellequelle

@ellequelle
Copy link
Contributor Author

thanks @ellequelle

👍

@ellequelle ellequelle deleted the interpbug branch October 25, 2019 14:08
HawkinsBA pushed a commit to HawkinsBA/pandas that referenced this pull request Oct 29, 2019
Reksbril pushed a commit to Reksbril/pandas that referenced this pull request Nov 18, 2019
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
bongolegend pushed a commit to bongolegend/pandas that referenced this pull request Jan 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NDFrame.interpolate(): variable 'ax' not assigned when axis='index'
6 participants