From aac8460c570d2f0f4dbe3ffbf747afd9240b3f07 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke Date: Fri, 7 Jan 2022 17:44:16 -0800 Subject: [PATCH 1/3] Remove pd.Panel checks --- xarray/core/dataarray.py | 2 -- xarray/core/merge.py | 2 +- xarray/core/pdcompat.py | 14 -------------- 3 files changed, 1 insertion(+), 17 deletions(-) diff --git a/xarray/core/dataarray.py b/xarray/core/dataarray.py index aa621a3c428..4a15fbe7827 100644 --- a/xarray/core/dataarray.py +++ b/xarray/core/dataarray.py @@ -400,8 +400,6 @@ def __init__( coords = [data.index, data.columns] elif isinstance(data, (pd.Index, IndexVariable)): coords = [data] - elif isinstance(data, pdcompat.Panel): - coords = [data.items, data.major_axis, data.minor_axis] if dims is None: dims = getattr(data, "dims", getattr(coords, "dims", None)) diff --git a/xarray/core/merge.py b/xarray/core/merge.py index a89e767826d..661881e014b 100644 --- a/xarray/core/merge.py +++ b/xarray/core/merge.py @@ -45,7 +45,7 @@ CoercibleMapping = Union[Dataset, Mapping[Any, CoercibleValue]] -PANDAS_TYPES = (pd.Series, pd.DataFrame, pdcompat.Panel) +PANDAS_TYPES = (pd.Series, pd.DataFrame) _VALID_COMPAT = Frozen( { diff --git a/xarray/core/pdcompat.py b/xarray/core/pdcompat.py index 18153e2ecad..fb4d951888b 100644 --- a/xarray/core/pdcompat.py +++ b/xarray/core/pdcompat.py @@ -1,6 +1,3 @@ -# The remove_unused_levels defined here was copied based on the source code -# defined in pandas.core.indexes.muli.py - # For reference, here is a copy of the pandas copyright notice: # (c) 2011-2012, Lambda Foundry, Inc. and PyData Development Team @@ -37,17 +34,6 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -import pandas as pd -from packaging.version import Version - -# allow ourselves to type checks for Panel even after it's removed -if Version(pd.__version__) < Version("0.25.0"): - Panel = pd.Panel -else: - - class Panel: # type: ignore[no-redef] - pass - def count_not_none(*args) -> int: """Compute the number of non-None arguments. From 52703b2eb6eebd8fe3861e272608ffe051c917a1 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke Date: Sat, 8 Jan 2022 14:38:47 -0800 Subject: [PATCH 2/3] Remove unused imports --- xarray/core/dataarray.py | 1 - xarray/core/merge.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/xarray/core/dataarray.py b/xarray/core/dataarray.py index 4a15fbe7827..b3ed6be94c9 100644 --- a/xarray/core/dataarray.py +++ b/xarray/core/dataarray.py @@ -32,7 +32,6 @@ groupby, indexing, ops, - pdcompat, resample, rolling, utils, diff --git a/xarray/core/merge.py b/xarray/core/merge.py index 661881e014b..460e02ae10f 100644 --- a/xarray/core/merge.py +++ b/xarray/core/merge.py @@ -19,7 +19,7 @@ import pandas as pd -from . import dtypes, pdcompat +from . import dtypes from .alignment import deep_align from .duck_array_ops import lazy_array_equiv from .indexes import Index, PandasIndex From 99baa74615556d2fe6c3a7324ec1fdb095dc364e Mon Sep 17 00:00:00 2001 From: Matthew Roeschke Date: Sat, 8 Jan 2022 20:47:30 -0800 Subject: [PATCH 3/3] Add whatsnew --- doc/whats-new.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index f8fe939b849..026d8a370d2 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -61,6 +61,9 @@ Internal Changes - Replace ``distutils.version`` with ``packaging.version`` (:issue:`6092`). By `Mathias Hauser `_. +- Removed internal checks for ``pd.Panel`` (:issue:`6145`). + By `Matthew Roeschke `_. + .. _whats-new.0.20.2: