From 8aca33b23962201a70b83c7cd353e345ed54af0e Mon Sep 17 00:00:00 2001 From: ilan-gold Date: Wed, 14 May 2025 11:06:51 +0200 Subject: [PATCH 1/5] (fix): docs for extension array index changes --- doc/whats-new.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index c8fbecf82af..fd0d2c1b8cc 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -75,7 +75,7 @@ New Features :py:meth:`Index.should_add_coord_to_array`. For example, this enables support for CF boundaries coordinate (e.g., ``time(time)`` and ``time_bnds(time, nbnd)``) in a DataArray (:pull:`10137`). By `Benoit Bovy `_. -- Improved support pandas categorical extension as indices (i.e., :py:class:`pandas.IntervalIndex`). (:issue:`9661`, :pull:`9671`) +- Improved support pandas extension array as indices (i.e., :py:class:`pandas.IntervalIndex`). (:issue:`9661`, :pull:`9671`) By `Ilan Gold `_. - Improved checks and errors raised when trying to align objects with conflicting indexes. It is now possible to align objects each with multiple indexes sharing common dimension(s). @@ -98,7 +98,10 @@ Breaking changes now return objects indexed by :py:meth:`pandas.IntervalArray` objects, instead of numpy object arrays containing tuples. This change enables interval-aware indexing of such Xarray objects. (:pull:`9671`). By `Ilan Gold `_. -- Remove ``PandasExtensionArrayIndex`` from :py:attr:`xarray.Variable.data` when the attribute is a :py:class:`pandas.api.extensions.ExtensionArray` (:pull:`10263`). By `Ilan Gold `_. +- By being more permissive about what pandas extension array indices are let through without casting, +there may be unexpected changes to functionality such as i/o or reductions (see above). +To return to previous functionality, ensure that extension arrays are cast to numpy arrays beforehand. (:pull:`9671`). By `Ilan Gold `_. +- Remove ``PandasExtensionArray`` from :py:attr:`xarray.Variable.data` when the attribute is a :py:class:`pandas.api.extensions.ExtensionArray` (:pull:`10263`). By `Ilan Gold `_. - The html and text ``repr`` for ``DataTree`` are now truncated. Up to 6 children are displayed for each node -- the first 3 and the last 3 children -- with a ``...`` between them. The number of children to include in the display is configurable via options. For instance use From cdb1c83da365789f381bbdc5eaf75c6d4c57a778 Mon Sep 17 00:00:00 2001 From: ilan-gold Date: Wed, 14 May 2025 11:08:11 +0200 Subject: [PATCH 2/5] (fix): small changes --- doc/whats-new.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index fd0d2c1b8cc..bf6af5c96cb 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -75,7 +75,7 @@ New Features :py:meth:`Index.should_add_coord_to_array`. For example, this enables support for CF boundaries coordinate (e.g., ``time(time)`` and ``time_bnds(time, nbnd)``) in a DataArray (:pull:`10137`). By `Benoit Bovy `_. -- Improved support pandas extension array as indices (i.e., :py:class:`pandas.IntervalIndex`). (:issue:`9661`, :pull:`9671`) +- Improved support for pandas extension array indices (i.e., :py:class:`pandas.IntervalIndex`). (:issue:`9661`, :pull:`9671`) By `Ilan Gold `_. - Improved checks and errors raised when trying to align objects with conflicting indexes. It is now possible to align objects each with multiple indexes sharing common dimension(s). @@ -98,7 +98,7 @@ Breaking changes now return objects indexed by :py:meth:`pandas.IntervalArray` objects, instead of numpy object arrays containing tuples. This change enables interval-aware indexing of such Xarray objects. (:pull:`9671`). By `Ilan Gold `_. -- By being more permissive about what pandas extension array indices are let through without casting, +- By being more permissive about what pandas extension array indices are let through without casting internally, there may be unexpected changes to functionality such as i/o or reductions (see above). To return to previous functionality, ensure that extension arrays are cast to numpy arrays beforehand. (:pull:`9671`). By `Ilan Gold `_. - Remove ``PandasExtensionArray`` from :py:attr:`xarray.Variable.data` when the attribute is a :py:class:`pandas.api.extensions.ExtensionArray` (:pull:`10263`). By `Ilan Gold `_. From fca772f3794e9252d3f1b897a6f5e437208199cd Mon Sep 17 00:00:00 2001 From: Ilan Gold Date: Fri, 16 May 2025 11:42:29 +0200 Subject: [PATCH 3/5] (fix): add small code help --- doc/whats-new.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index bf6af5c96cb..f246c7c4546 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -60,6 +60,8 @@ This release brings bug fixes, better support for extension arrays including ret Thanks to the 24 contributors to this release: Alban Farchi, Andrecho, Benoit Bovy, Deepak Cherian, Dimitri Papadopoulos Orfanos, Florian Jetter, Giacomo Caria, Ilan Gold, Illviljan, Joren Hammudoglu, Julia Signell, Kai Muehlbauer, Kai Mühlbauer, Mathias Hauser, Mattia Almansi, Michael Sumner, Miguel Jimenez, Nick Hodgskin (🦎 Vecko), Pascal Bourgault, Philip Chmielowiec, Scott Henderson, Spencer Clark, Stephan Hoyer and Tom Nicholas +A number of changes involve :py:class:`pandas.api.extensions.ExtensionDtype` (as an index or `Variable.data`). To convert to `numpy`, you can use `numpy.asarray`, converting to a :py:class:`pandas.Series` and then calling :py:meth:`pandas.Series.to_numpy`, or `pandas.api.extensions.ExtensionArray.astype` with a `numpy` type. + New Features ~~~~~~~~~~~~ From 02ef10c951d2e1c844a6a6a29b5cd5573fdabfcb Mon Sep 17 00:00:00 2001 From: Ilan Gold Date: Fri, 16 May 2025 11:43:11 +0200 Subject: [PATCH 4/5] (fix): intersphinx --- doc/whats-new.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index f246c7c4546..33eaca7e90f 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -60,7 +60,7 @@ This release brings bug fixes, better support for extension arrays including ret Thanks to the 24 contributors to this release: Alban Farchi, Andrecho, Benoit Bovy, Deepak Cherian, Dimitri Papadopoulos Orfanos, Florian Jetter, Giacomo Caria, Ilan Gold, Illviljan, Joren Hammudoglu, Julia Signell, Kai Muehlbauer, Kai Mühlbauer, Mathias Hauser, Mattia Almansi, Michael Sumner, Miguel Jimenez, Nick Hodgskin (🦎 Vecko), Pascal Bourgault, Philip Chmielowiec, Scott Henderson, Spencer Clark, Stephan Hoyer and Tom Nicholas -A number of changes involve :py:class:`pandas.api.extensions.ExtensionDtype` (as an index or `Variable.data`). To convert to `numpy`, you can use `numpy.asarray`, converting to a :py:class:`pandas.Series` and then calling :py:meth:`pandas.Series.to_numpy`, or `pandas.api.extensions.ExtensionArray.astype` with a `numpy` type. +A number of changes involve :py:class:`pandas.api.extensions.ExtensionDtype` (as an index or `Variable.data`). To convert to `numpy`, you can use :py:meth:`numpy.asarray`, converting to a :py:class:`pandas.Series` and then calling :py:meth:`pandas.Series.to_numpy`, or `pandas.api.extensions.ExtensionArray.astype` with a `numpy` type. New Features ~~~~~~~~~~~~ From 0fb7bdacc2bb546c97aa9e441bd53261a8f14653 Mon Sep 17 00:00:00 2001 From: Ilan Gold Date: Fri, 16 May 2025 17:13:18 +0200 Subject: [PATCH 5/5] (fix): make clear how to get the extension array --- doc/whats-new.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 33eaca7e90f..0f75d47e3d6 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -60,7 +60,7 @@ This release brings bug fixes, better support for extension arrays including ret Thanks to the 24 contributors to this release: Alban Farchi, Andrecho, Benoit Bovy, Deepak Cherian, Dimitri Papadopoulos Orfanos, Florian Jetter, Giacomo Caria, Ilan Gold, Illviljan, Joren Hammudoglu, Julia Signell, Kai Muehlbauer, Kai Mühlbauer, Mathias Hauser, Mattia Almansi, Michael Sumner, Miguel Jimenez, Nick Hodgskin (🦎 Vecko), Pascal Bourgault, Philip Chmielowiec, Scott Henderson, Spencer Clark, Stephan Hoyer and Tom Nicholas -A number of changes involve :py:class:`pandas.api.extensions.ExtensionDtype` (as an index or `Variable.data`). To convert to `numpy`, you can use :py:meth:`numpy.asarray`, converting to a :py:class:`pandas.Series` and then calling :py:meth:`pandas.Series.to_numpy`, or `pandas.api.extensions.ExtensionArray.astype` with a `numpy` type. +A number of changes involve :py:class:`pandas.api.extensions.ExtensionDtype` (as an index or `Variable.data`). To convert to `numpy`, you can use :py:meth:`numpy.asarray`, converting to a :py:class:`pandas.Series` and then calling :py:meth:`pandas.Series.to_numpy`, or `pandas.api.extensions.ExtensionArray.astype` with a `numpy` type. Note that the underlying :py:class:`pandas.api.extensions.ExtensionArray` is itself always available at ``.data`` whether a :py:class:`xarray.Variable` or :py:class:`xarray.DataArray`. New Features ~~~~~~~~~~~~