Skip to content

Commit

Permalink
Backport PR #57510 on branch 2.2.x (DOC: Fix xarray example) (#57538)
Browse files Browse the repository at this point in the history
DOC: Fix xarray example (#57510)

* DOC: Fix xarray example

* Update

* Skip doctest

* Igore another doctest

---------

Co-authored-by: Matthew Roeschke <[email protected]>

(cherry picked from commit 33a1cd7)
  • Loading branch information
phofl authored Feb 20, 2024
1 parent 0b49cf3 commit c101d30
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3278,18 +3278,18 @@ def to_xarray(self):
2 lion mammal 80.5 4
3 monkey mammal NaN 4
>>> df.to_xarray()
>>> df.to_xarray() # doctest: +SKIP
<xarray.Dataset>
Dimensions: (index: 4)
Coordinates:
* index (index) int64 0 1 2 3
* index (index) int64 32B 0 1 2 3
Data variables:
name (index) object 'falcon' 'parrot' 'lion' 'monkey'
class (index) object 'bird' 'bird' 'mammal' 'mammal'
max_speed (index) float64 389.0 24.0 80.5 nan
num_legs (index) int64 2 2 4 4
name (index) object 32B 'falcon' 'parrot' 'lion' 'monkey'
class (index) object 32B 'bird' 'bird' 'mammal' 'mammal'
max_speed (index) float64 32B 389.0 24.0 80.5 nan
num_legs (index) int64 32B 2 2 4 4
>>> df['max_speed'].to_xarray()
>>> df['max_speed'].to_xarray() # doctest: +SKIP
<xarray.DataArray 'max_speed' (index: 4)>
array([389. , 24. , 80.5, nan])
Coordinates:
Expand All @@ -3311,7 +3311,7 @@ class (index) object 'bird' 'bird' 'mammal' 'mammal'
2018-01-02 falcon 361
parrot 15
>>> df_multiindex.to_xarray()
>>> df_multiindex.to_xarray() # doctest: +SKIP
<xarray.Dataset>
Dimensions: (date: 2, animal: 2)
Coordinates:
Expand Down

0 comments on commit c101d30

Please sign in to comment.