7
7
from numpy import nan
8
8
import pandas as pd
9
9
10
+ from distutils .version import LooseVersion
10
11
from pandas .types .common import is_scalar
11
12
from pandas import (Index , Series , DataFrame , Panel , isnull ,
12
13
date_range , period_range , Panel4D )
@@ -870,6 +871,7 @@ def test_describe_none(self):
870
871
def test_to_xarray (self ):
871
872
872
873
tm ._skip_if_no_xarray ()
874
+ import xarray
873
875
from xarray import DataArray
874
876
875
877
s = Series ([])
@@ -895,15 +897,16 @@ def testit(index, check_index_type=True, check_categorical=True):
895
897
check_index_type = check_index_type ,
896
898
check_categorical = check_categorical )
897
899
898
- for index in [tm .makeFloatIndex , tm .makeIntIndex ,
899
- tm .makeStringIndex , tm .makeUnicodeIndex ,
900
- tm .makeDateIndex , tm .makePeriodIndex ,
901
- tm .makeTimedeltaIndex ]:
902
- testit (index )
900
+ l = [tm .makeFloatIndex , tm .makeIntIndex ,
901
+ tm .makeStringIndex , tm .makeUnicodeIndex ,
902
+ tm .makeDateIndex , tm .makePeriodIndex ,
903
+ tm .makeTimedeltaIndex ]
904
+
905
+ if LooseVersion (xarray .__version__ ) >= '0.8.0' :
906
+ l .append (tm .makeCategoricalIndex )
903
907
904
- # not idempotent
905
- testit (tm .makeCategoricalIndex , check_index_type = False ,
906
- check_categorical = False )
908
+ for index in l :
909
+ testit (index )
907
910
908
911
s = Series (range (6 ))
909
912
s .index .name = 'foo'
0 commit comments