Informatics Practices

Create a dataframe of {‘A’ : [ ]} and display whether it is empty or not.

Python Data Handling

3 Likes

Answer

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.

Answered By

1 Like


Related Questions