How to check whether a Pandas DataFrame is empty?

Given a DataFrame, we have to check whether a Pandas DataFrame is empty.
Submitted by Pranit Sharma, on April 29, 2022

Pandas is a special tool that allows us to perform complex manipulations of data effectively and efficiently. Inside pandas, we mostly deal with a dataset in the form of DataFrame. DataFrames are 2-dimensional data structures in pandas. DataFrames consists of rows, columns, and the data. A certain operation can be performed on DataFrames.

In pandas, we can check if a DataFrame is empty or not by using the following syntax:



By using the above syntax, we will get a Boolean value i.e., True if the DataFrame is empty and False if a DataFrame is not empty.

To work with Python Pandas, we need to import the pandas library. Below is the syntax,

import pandas as pd

Let us understand with the help of an example.

# Importing pandas package
import pandas as pd

# Creating an Empty dictionary
d = {}

# Creating an Empty DataFrame first

# Check if DataFrame is empty or 
# not DataFrame
result = df.empty

# Display result



Python Pandas Programs »


Comments and Discussions!

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© some rights reserved.