Skip to content

BUG: np.argwhere on pandas series #35331

Closed
@rossbar

Description

@rossbar
  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • (optional) I have confirmed this bug exists on the master branch of pandas.


numpy/numpy#15555 reports an issue with np.argwhere on pandas Series. Reporting here for visibility.

MRE:

>>> import numpy as np
>>> import pandas as pd
>>> s = pd.Series(np.random.randn(5), index=['a', 'b', 'c', 'd', 'e'])
>>> np.argwhere(s < 0)

which, with numpy.__version__ ==1.20.0.dev0+046a736 gives:
pd.version == 0.25.3:

FutureWarning: Series.nonzero() is deprecated and will be removed in a future version.Use Series.to_numpy().nonzero() instead
array([[3]])

pd.version == 1.0.5:

ValueError: Length of passed values is 1, index implies 5.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions