Consider this dataframe:
name age scores
0 Alice 8 (False, 0, 89.1)
1 Bob 7 (True, 136, 79.05)
2 Chuck 9 (True, 138, 75.0)
3 Daren 12 (True, 146, 77.25)
3 Elisa 13 (True, 146, 77.25)
Now, I want to filter the dataframe to include only those entries with True in the first position of the 'scores' tuple, to obtain this dataframe :
name age scores
1 Bob 7 (True, 136, 79.05)
2 Chuck 9 (True, 138, 75.0)
3 Daren 12 (True, 146, 77.25)
3 Elisa 13 (True, 146, 77.25)
I have tried both of these:
df = df[df.scores[0] == True]
and
df = df.drop(df[df.scores[0] == False].index)
But I keep getting errors. Does anyone know of an efficient way to filter by value in a tuple? Thanks!