How to check whether a pandas DataFrame is empty?

Question

How to check whether a pandas DataFrame is empty? In my case I want to print some message in terminal if the DataFrame is empty.

Answer

You can use the attribute df.empty to check whether it's empty or not:

if df.empty:
    print('DataFrame is empty!')

Source: Pandas Documentation

How to drop rows of Pandas DataFrame whose value in a certain column is NaN

Python Pandas Error tokenizing data