You can use boolean indexing to subset the dataframe based on a condition and then get the index values of the resulting subset.
Here's an example:
main.py274 chars13 lines
Output:
main.py34 chars2 lines
In this example, we first create a sample dataframe with two columns 'a' and 'b'. We then subset the dataframe based on the condition df['a'] > 2
, which selects all rows where column 'a' is greater than 2. Finally, we get the index values of the resulting subset using the .index
attribute of the dataframe.
gistlibby LogSnag