Skip to content

TST: DataFrame.interpolate(axis='columns') throws exception while DataFrame.interpolate(axis=1) not (#25190) #31566

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v1.1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ Indexing
- Bug in :meth:`PeriodIndex.is_monotonic` incorrectly returning ``True`` when containing leading ``NaT`` entries (:issue:`31437`)
- Bug in :meth:`DatetimeIndex.get_loc` raising ``KeyError`` with converted-integer key instead of the user-passed key (:issue:`31425`)
- Bug in :meth:`Series.xs` incorrectly returning ``Timestamp`` instead of ``datetime64`` in some object-dtype cases (:issue:`31630`)
- Bug in :meth:`DataFrame.interpolate` raising ``UnboundLocalError`` when specifying the ``axis`` with a string (:issue:`25190`)
Copy link
Contributor

Choose a reason for hiding this comment

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

pls remove this; the bug was already fixed and this is confusing.


Missing
^^^^^^^
Expand Down
8 changes: 8 additions & 0 deletions pandas/tests/frame/test_missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -983,3 +983,11 @@ def test_interp_time_inplace_axis(self, axis):
result = expected.interpolate(axis=0, method="time")
expected.interpolate(axis=0, method="time", inplace=True)
tm.assert_frame_equal(result, expected)

def test_interp_string_axis(self):
# GH 25190
Copy link
Member

Choose a reason for hiding this comment

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

can you add a few words here so the reader doesnt need to look up 25190? very brief is OK

x = np.linspace(0, 100, 1000)
y = np.sin(x)
df = pd.DataFrame(data=np.tile(y, (10, 1)), index=np.arange(10), columns=x)
df.reindex(columns=x * 1.005).interpolate(method="linear", axis="columns")
df.reindex(columns=x * 1.005).interpolate(method="linear", axis="index")
Copy link
Member

Choose a reason for hiding this comment

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

@jbrockmendel : Does it make sense to also check the results?

Copy link
Member

Choose a reason for hiding this comment

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

i think that'd be worthwhile if it isnt too onerous. if nothing else, could check that we get the same result as we would if we passed the ints instead of strings.

@YagoGG o do we need the corresponding tests for Series?