Skip to content

index where, first_index_where, first_value_where, first_valid_value #4616

Closed
@hayd

Description

@hayd

I've thrown in a few functions which I think are similar (but I've seen a few times asked about). e.g. this SO question.

User wants to get the index where a criteria is true:

import pandas as pd
myseries = pd.Series([1,4,0,7,5], index=[0,1,2,3,4])
print myseries.find(7) # should output 3

I guess the usual way is to use:

s[msk].index
s[msk].index[0]

Or as @jreback suggests (in this simple example):

pd.index(s).get_loc(7)

Perhaps there should be some methods to grab these out efficiently (i.e. short-circuit in cython)... maybe it makes more sense to have a crit function rather than a mask.

cc @cpcloud

also similar to idxmax and idxmin.

Metadata

Metadata

Assignees

No one assigned

    Labels

    API DesignClosing CandidateMay be closeable, needs more eyeballsEnhancementIndexingRelated 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