Skip to content

Commit

Permalink
Backport PR #35543: REGR: Fix interpolation on empty dataframe (#35764)
Browse files Browse the repository at this point in the history
Co-authored-by: sanderland <48946947+sanderland@users.noreply.github.com>
  • Loading branch information
meeseeksmachine and sanderland committed Aug 17, 2020
1 parent 56e95ad commit 7a5d186
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/source/whatsnew/v1.1.1.rst
Expand Up @@ -19,6 +19,7 @@ Fixed regressions
- Fixed regression where :func:`read_csv` would raise a ``ValueError`` when ``pandas.options.mode.use_inf_as_na`` was set to ``True`` (:issue:`35493`)
- Fixed regression where :func:`pandas.testing.assert_series_equal` would raise an error when non-numeric dtypes were passed with ``check_exact=True`` (:issue:`35446`)
- Fixed regression in :class:`pandas.core.groupby.RollingGroupby` where column selection was ignored (:issue:`35486`)
- Fixed regression where :meth:`DataFrame.interpolate` would raise a ``TypeError`` when the :class:`DataFrame` was empty (:issue:`35598`).
- Fixed regression in :meth:`DataFrame.shift` with ``axis=1`` and heterogeneous dtypes (:issue:`35488`)
- Fixed regression in :meth:`DataFrame.diff` with read-only data (:issue:`35559`)
- Fixed regression in ``.groupby(..).rolling(..)`` where a segfault would occur with ``center=True`` and an odd number of values (:issue:`35552`)
Expand Down
3 changes: 3 additions & 0 deletions pandas/core/generic.py
Expand Up @@ -6799,6 +6799,9 @@ def interpolate(

obj = self.T if should_transpose else self

if obj.empty:
return self

if method not in fillna_methods:
axis = self._info_axis_number

Expand Down
7 changes: 7 additions & 0 deletions pandas/tests/frame/methods/test_interpolate.py
Expand Up @@ -34,6 +34,13 @@ def test_interp_basic(self):
expected.loc[5, "B"] = 9
tm.assert_frame_equal(result, expected)

def test_interp_empty(self):
# https://github.com/pandas-dev/pandas/issues/35598
df = DataFrame()
result = df.interpolate()
expected = df
tm.assert_frame_equal(result, expected)

def test_interp_bad_method(self):
df = DataFrame(
{
Expand Down

0 comments on commit 7a5d186

Please sign in to comment.