How to Check Whether a Pandas Dataframe is Empty

Spread the love

Problem –

You have a dataframe and you want to know whether it is empty or not?

Solution –

In pandas, you can use the df.empty attribute to know whether a dataframe is empty or not.

if df.empty:
    print("DataFrame is empty!")
    print("DataFrame is not empty!")

Rating: 1 out of 5.

Leave a Reply