Skip to content

Commit f2057b1

Browse files
committed
Raise NotImplementedError when attempting to use a pandas.MultiIndex
Related: pydata#164
1 parent 20d1939 commit f2057b1

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

test/test_data_array.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,10 @@ def test_constructor_from_self_described(self):
198198
actual = DataArray(Coordinate('foo', ['a', 'b']))
199199
self.assertDataArrayIdentical(expected, actual)
200200

201+
s = pd.Series(range(2), pd.MultiIndex.from_product([['a', 'b'], [0]]))
202+
with self.assertRaisesRegexp(NotImplementedError, 'MultiIndex'):
203+
DataArray(s)
204+
201205
def test_equals_and_identical(self):
202206
da2 = self.dv.copy()
203207
self.assertTrue(self.dv.equals(da2))

xray/variable.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,11 @@ class Coordinate(Variable):
718718
_cache_data_class = PandasIndexAdapter
719719

720720
def __init__(self, name, data, attributes=None, encoding=None):
721+
if isinstance(data, pd.MultiIndex):
722+
raise NotImplementedError(
723+
'no support yet for using a pandas.MultiIndex in an '
724+
'xray.Coordinate')
725+
721726
super(Coordinate, self).__init__(name, data, attributes, encoding)
722727
if self.ndim != 1:
723728
raise ValueError('%s objects must be 1-dimensional' %

0 commit comments

Comments
 (0)