CBSE Class 12 Informatics Practices
Question 39 of 44
Data Handling using Pandas — Question 40
Back to all questions 40
Question Create a dataframe of {‘A’ : [ ]} and display whether it is empty or not.
import pandas as pd
df = pd.DataFrame({'A': []})
print(df)
if df.empty:
print("The dataframe is empty.")
else:
print("The dataframe is not empty.")Empty DataFrame
Columns: [A]
Index: []
The dataframe is empty.
import
pandas
as
pd
df
=
pd
.
DataFrame
({
'A'
: []})
print
(
df
)
if
df
.
empty
:
print
(
"The dataframe is empty."
)
else
:
print
(
"The dataframe is not empty."
)
Output
Empty DataFrame
Columns: [A]
Index: []
The dataframe is empty.