Skip to content

Commit e78c61f

Browse files
committed
DOC: fix doc builds w.r.t. to_xarray
1 parent d207679 commit e78c61f

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

pandas/core/generic.py

+30-2
Original file line numberDiff line numberDiff line change
@@ -1050,9 +1050,37 @@ def to_xarray(self):
10501050
a Dataset for a DataFrame
10511051
a DataArray for higher dims
10521052
1053-
See Also
1053+
Examples
10541054
--------
1055-
`xarray docs <http://xarray.pydata.org/en/stable/>`__
1055+
>>> df = DataFrame({'A' : [1, 2, 3], 'B' : ['foo', 'bar', 'baz']})
1056+
>>> df.to_xarray()
1057+
<xarray.Dataset>
1058+
Dimensions: (index: 3)
1059+
Coordinates:
1060+
* index (index) int64 0 1 2
1061+
Data variables:
1062+
A (index) int64 1 2 3
1063+
B (index) object 'foo' 'bar' 'baz'
1064+
1065+
>>> p = pd.Panel(np.arange(6).reshape(3,2,1))
1066+
>>> p.to_xarray()
1067+
<xarray.DataArray (items: 3, major_axis: 2, minor_axis: 1)>
1068+
array([[[0],
1069+
[1]],
1070+
1071+
[[2],
1072+
[3]],
1073+
1074+
[[4],
1075+
[5]]])
1076+
Coordinates:
1077+
* items (items) int64 0 1 2
1078+
* major_axis (major_axis) int64 0 1
1079+
* minor_axis (minor_axis) int64 0
1080+
1081+
Notes
1082+
-----
1083+
See also the `xarray docs <http://xarray.pydata.org/en/stable/>`__
10561084
"""
10571085
import xarray
10581086
if self.ndim == 1:

0 commit comments

Comments
 (0)