Skip to content

index where, first_index_where, first_value_where, first_valid_value #4616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hayd opened this issue Aug 20, 2013 · 2 comments
Closed

index where, first_index_where, first_value_where, first_valid_value #4616

hayd opened this issue Aug 20, 2013 · 2 comments
Labels
API Design Closing Candidate May be closeable, needs more eyeballs Enhancement Indexing Related to indexing on series/frames, not to indexes themselves

Comments

@hayd
Copy link
Contributor

hayd commented Aug 20, 2013

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.

@ghost ghost assigned hayd Dec 10, 2013
@jreback jreback modified the milestones: 0.15.0, 0.14.0 Mar 11, 2014
@jreback jreback modified the milestones: 0.16.0, Next Major Release Mar 3, 2015
@datapythonista datapythonista modified the milestones: Contributions Welcome, Someday Jul 8, 2018
@rhshadrach
Copy link
Member

-1, I find the mask approach to be sufficient here.

@rhshadrach rhshadrach added the Closing Candidate May be closeable, needs more eyeballs label Feb 12, 2021
@mroeschke
Copy link
Member

Agreed, closing as there hasn't been much activity for this feature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Closing Candidate May be closeable, needs more eyeballs Enhancement Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

No branches or pull requests

5 participants