idxmax
and argmax
will return the position of the maximal value or the first position if the maximal value occurs more than once.
use idxmax
on df.A.ne('a')
df.A.ne('a').idxmax()
3
or the numpy
equivalent
(df.A.values != 'a').argmax()
3
However, if A
has already been sorted, then we can use searchsorted
df.A.searchsorted('a', side="right")
array([3])
Or the numpy
equivalent
df.A.values.searchsorted('a', side="right")
3
Related Contents:
- Get statistics for each group (such as count, mean, etc) using pandas GroupBy?
- Get the row(s) which have the max value in groups using groupby
- How do I Pandas group-by to get sum?
- Pandas dataframe get first row of each group
- How to access pandas groupby dataframe by key
- Pandas groupby cumulative sum
- Python: get a frequency count based on two columns (variables) in pandas dataframe some row appers
- Group dataframe and get sum AND count?
- Python Pandas How to assign groupby operation results back to columns in parent dataframe?
- Difference between groupby and pivot_table
- How to get number of groups in a groupby object in pandas?
- Add a sequential counter column on groups to a pandas dataframe
- Difference between groupby and pivot_table for pandas dataframes
- Get frequency of item occurrences in a column as percentage [duplicate]
- Ranking order per group in Pandas
- Python pandas: Add a column to my dataframe that counts a variable
- Pandas sort by group aggregate and column
- How can I use cumsum within a group in Pandas?
- Sorting columns and selecting top n rows in each group pandas dataframe
- Pandas groupby with bin counts
- Pandas Groupby: Count and mean combined
- How to groupby consecutive values in pandas DataFrame
- How do I select rows from a DataFrame based on column values?
- Combining two Series into a DataFrame in pandas
- Add column to dataframe with constant value
- Filtering Pandas DataFrames on dates
- How to filter rows containing a string pattern from a Pandas dataframe [duplicate]
- How to show all columns’ names on a large pandas dataframe?
- Can pandas automatically read dates from a CSV file?
- What is dtype(‘O’), in pandas?
- pandas how to check dtype for all columns in a dataframe?
- Move column by name to front of table in pandas
- What values are valid in Pandas ‘Freq’ tags?
- Pandas DataFrame stored list as string: How to convert back to list
- Python pandas: how to specify data types when reading an Excel file?
- Retrieve DataFrame of all but one specified column [duplicate]
- Pandas merge two dataframes with different columns
- Finding common rows (intersection) in two Pandas dataframes
- Merge multiple column values into one column in python pandas
- Transform a Counter object into a Pandas DataFrame
- Accessing every 1st element of Pandas DataFrame column containing lists
- UnicodeDecodeError when reading CSV file in Pandas
- Create a set from a series in pandas
- how to read certain columns from Excel using Pandas – Python
- df.unique() on whole DataFrame based on a column
- How to drop a specific column of csv file while reading it using pandas?
- How do I assign values based on multiple conditions for existing columns?
- How to pivot a dataframe in Pandas? [duplicate]
- which is faster for load: pickle or hdf5 in python
- Normalizing pandas DataFrame rows by their sums