Is there a possibility to get the first value from a filtered dataframe without having to copy and reindexing the whole dataframe?
Lets say I have a dataframe df:
index | statement | name |
---|---|---|
1 | True | 123 |
2 | True | 456 |
3 | True | 789 |
4 | False | 147 |
5 | False | 258 |
6 | True | 369 |
and I want to get the name of the first row with statement that is False.
I would do:
filtered_df = df[df.statement == False]
filtered_df = reset_index(drop=True)
name = filtered_df.loc[0, "name"]
but is there an easier/faster solution to this?