Skip to content

BUG: Slicing multi Index with one column by column errors out #6788

Closed
@rdooley

Description

@rdooley

The following code errors out. Seems like it should just return the original dataframe.
pandas: 0.13.1-552-g8120a59

import pandas as pd
import numpy as np
from itertools import product

attributes = ['Attribute' + str(i) for i in range(1)]
attribute_values = ['Value' + str(i) for i in range(1000)]

index = pd.MultiIndex.from_tuples(list(product(attributes, attribute_values)))
df = 0.1 * np.random.randn(10, 1 * 1000) + 0.5
df = pd.DataFrame(df, columns=index)

df[attributes]

Stacktrace

(pandas)pandas git:master ❯ python example_failure.py                                                                                                                                                                                ✭
Traceback (most recent call last):
  File "example_failure.py", line 12, in <module>
    df[attributes]
  File "PATH/pandas/pandas/core/frame.py", line 1672, in __getitem__
    return self._getitem_array(key)
  File "PATH/pandas/pandas/core/frame.py", line 1717, in _getitem_array
    return self.take(indexer, axis=1, convert=True)
  File "PATH/pandas/pandas/core/generic.py", line 1224, in take
    indices, len(self._get_axis(axis)))
  File "PATH/pandas/pandas/core/indexing.py", line 1564, in _maybe_convert_indices
    if mask.any():
AttributeError: 'bool' object has no attribute 'any'

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions