From a2816ca972d94410f8c6defb8acf2798edc39e01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yago=20Gonz=C3=A1lez?= Date: Sun, 2 Feb 2020 10:41:57 +0100 Subject: [PATCH 1/2] TST: add regression tests for fixed issue (#25190) Make sure that DataFrame.interpolate allows setting having "columns" or "index" as the axis argument. --- pandas/tests/frame/test_missing.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pandas/tests/frame/test_missing.py b/pandas/tests/frame/test_missing.py index ae0516dd29a1f..7263c9335f139 100644 --- a/pandas/tests/frame/test_missing.py +++ b/pandas/tests/frame/test_missing.py @@ -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 + 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") From e80d8b2ffceecfea2a8ed6d406462fdd3669eca0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yago=20Gonz=C3=A1lez?= Date: Sun, 2 Feb 2020 10:47:39 +0100 Subject: [PATCH 2/2] DOC: add whatsnew entry for bug fix (#25190) --- doc/source/whatsnew/v1.1.0.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/whatsnew/v1.1.0.rst b/doc/source/whatsnew/v1.1.0.rst index 40abb8f83de2f..c062cdee92145 100644 --- a/doc/source/whatsnew/v1.1.0.rst +++ b/doc/source/whatsnew/v1.1.0.rst @@ -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`) Missing ^^^^^^^