Skip to content

Commit 203c3f4

Browse files
authored
remove panel conversion (#3845)
1 parent 603b0ad commit 203c3f4

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

doc/whats-new.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ Internal Changes
9595
By `Bruno Pagani <https://github.com/ArchangeGabriel>`_.
9696
- Updated Azure CI MacOS image, given pending removal.
9797
By `Maximilian Roos <https://github.com/max-sixty>`_
98+
- Removed conversion to :py:class:`pandas.Panel`, given its removal in pandas
99+
in favor of xarray's objects.
100+
By `Maximilian Roos <https://github.com/max-sixty>`_
98101

99102
.. _whats-new.0.15.0:
100103

xarray/core/dataarray.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2243,20 +2243,14 @@ def to_pandas(self) -> Union["DataArray", pd.Series, pd.DataFrame]:
22432243
* 0D -> `xarray.DataArray`
22442244
* 1D -> `pandas.Series`
22452245
* 2D -> `pandas.DataFrame`
2246-
* 3D -> `pandas.Panel` *(deprecated)*
22472246
2248-
Only works for arrays with 3 or fewer dimensions.
2247+
Only works for arrays with 2 or fewer dimensions.
22492248
22502249
The DataArray constructor performs the inverse transformation.
22512250
"""
22522251
# TODO: consolidate the info about pandas constructors and the
22532252
# attributes that correspond to their indexes into a separate module?
2254-
constructors = {
2255-
0: lambda x: x,
2256-
1: pd.Series,
2257-
2: pd.DataFrame,
2258-
3: pdcompat.Panel,
2259-
}
2253+
constructors = {0: lambda x: x, 1: pd.Series, 2: pd.DataFrame}
22602254
try:
22612255
constructor = constructors[self.ndim]
22622256
except KeyError:

xarray/tests/test_dataarray.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3411,14 +3411,10 @@ def test_to_pandas(self):
34113411
assert_array_equal(actual.columns, [0, 1])
34123412

34133413
# roundtrips
3414-
for shape in [(3,), (3, 4), (3, 4, 5)]:
3415-
if len(shape) > 2 and LooseVersion(pd.__version__) >= "0.25.0":
3416-
continue
3414+
for shape in [(3,), (3, 4)]:
34173415
dims = list("abc")[: len(shape)]
34183416
da = DataArray(np.random.randn(*shape), dims=dims)
3419-
with warnings.catch_warnings():
3420-
warnings.filterwarnings("ignore", r"\W*Panel is deprecated")
3421-
roundtripped = DataArray(da.to_pandas()).drop_vars(dims)
3417+
roundtripped = DataArray(da.to_pandas()).drop_vars(dims)
34223418
assert_identical(da, roundtripped)
34233419

34243420
with raises_regex(ValueError, "cannot convert"):

0 commit comments

Comments
 (0)