Skip to content

Commit

Permalink
DOC: Fix xarray example (#57510)
Browse files Browse the repository at this point in the history
* DOC: Fix xarray example

* Update

* Skip doctest

* Igore another doctest

---------

Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com>
  • Loading branch information
phofl and mroeschke committed Feb 20, 2024
1 parent 5a862b5 commit 33a1cd7
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions pandas/core/generic.py
Expand Up @@ -3120,18 +3120,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 @@ -3157,7 +3157,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 33a1cd7

Please sign in to comment.