Skip to content

Using boolean Series to mask array broken in 0.13 #5776

Closed
@mwaskom

Description

@mwaskom

Hi, I'm testing out some code on the 0.13 release candidate and I've run into problems with a fairly common (for me) pattern. It's no longer possible to use a boolean Series to index a numpy array. E.g.:

import numpy as np
import pandas as pd
x = np.random.randn(30)
mask = pd.Series(np.random.rand(30) > .5)
x[mask].mean()

Raises:

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-27-73e40e756b4e> in <module>()
      3 x = np.random.randn(30)
      4 mask = pd.Series(np.random.rand(30) > .5)
----> 5 x[mask].mean()

IndexError: unsupported iterator index

Perhaps this is not a good idiom, but this change breaks quite a bit of existing code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    API DesignIndexingRelated to indexing on series/frames, not to indexes themselves

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions