We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4dcb998 commit 18a428dCopy full SHA for 18a428d
pandas/core/generic.py
@@ -1501,7 +1501,17 @@ def to_xarray(self):
1501
-----
1502
See the `xarray docs <http://xarray.pydata.org/en/stable/>`__
1503
"""
1504
- import xarray
+
1505
+ try:
1506
+ import xarray
1507
+ except ImportError:
1508
+ # Give a nice error message
1509
+ raise ImportError("the xarray library is not installed\n"
1510
+ "you can install via conda\n"
1511
+ "conda install xarray\n"
1512
+ "or via pip\n"
1513
+ "pip install xarray\n")
1514
1515
if self.ndim == 1:
1516
return xarray.DataArray.from_series(self)
1517
elif self.ndim == 2:
0 commit comments