Skip to content Skip to sidebar Skip to footer

Pandaic Way To Check Whether A Dataframe Has Any Rows

Given a dataframe df, I'd apply some condition df[condition] and retrieve a subset. I just want to check if there are any rows in the subset - this would tell me the condition is a

Solution 1:

You could use df.empty:

df_conditional = df.loc[df['column_name'] == some_value]
if not df_conditional.empty:
    ... # process dataframe results

Post a Comment for "Pandaic Way To Check Whether A Dataframe Has Any Rows"