BUG: validate Index data is 1D + deprecate multi-dim indexing by jbrockmendel · Pull Request #30588 · pandas-dev/pandas (original) (raw)

There is a feather test in which we do

@jbrockmendel that test setup looks bad. We're assigning a length-1 tuple whose only element is a MultiIndex to be the single key?

In [7]: df = pd.DataFrame({"A": [1, 2, 3]})

In [8]: df.columns = pd.MultiIndex.from_tuples([("a", 1), ("a", 2), ("a", 3)]),

In [9]: df Out[9]: --------------------------------------------------------------------------- ValueError Traceback (most recent call last) ~/sandbox/pandas/pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.map_locations() 1637 raise KeyError(key) 1638 -> 1639 def map_locations(self, ndarray[object] values): 1640 cdef: 1641 Py_ssize_t i, n = len(values)

ValueError: Buffer has wrong number of dimensions (expected 1, got 3) Exception ignored in: 'pandas._libs.index.IndexEngine._call_map_locations' Traceback (most recent call last): File "pandas/_libs/hashtable_class_helper.pxi", line 1639, in pandas._libs.hashtable.PyObjectHashTable.map_locations def map_locations(self, ndarray[object] values): ValueError: Buffer has wrong number of dimensions (expected 1, got 3)

I think we'd rather have a length-1 MultiIndex

diff --git a/pandas/tests/io/test_feather.py b/pandas/tests/io/test_feather.py index e06f2c31a2..3500470035 100644 --- a/pandas/tests/io/test_feather.py +++ b/pandas/tests/io/test_feather.py @@ -136,7 +136,7 @@ class TestFeather:

     # column multi-index
     df.index = [0, 1, 2]