Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Checks if the DataFrame is empty and returns a boolean value.
Syntax
isEmpty()
Returns
bool: Returns True if the DataFrame is empty, False otherwise.
Notes
An empty DataFrame has no rows. It may have columns, but no data.
Examples
df_empty = spark.createDataFrame([], 'a STRING')
df_empty.isEmpty()
# True
df_non_empty = spark.createDataFrame(["a"], 'STRING')
df_non_empty.isEmpty()
# False
df_nulls = spark.createDataFrame([(None, None)], 'a STRING, b INT')
df_nulls.isEmpty()
# False
df_no_rows = spark.createDataFrame([], 'id INT, value STRING')
df_no_rows.isEmpty()
# True