nxcals.api.extraction.data.builders.DataFrame.isEmpty
- DataFrame.isEmpty() bool
Checks if the
DataFrameis empty and returns a boolean value.Added in version 3.3.0.
Changed in version 3.4.0: Supports Spark Connect.
- Returns:
Returns
Trueif the DataFrame is empty,Falseotherwise.- Return type:
bool
See also
DataFrame.countCounts the number of rows in DataFrame.
Notes
An empty DataFrame has no rows. It may have columns, but no data.
Examples
Example 1: Checking if an empty DataFrame is empty
>>> df_empty = spark.createDataFrame([], 'a STRING') >>> df_empty.isEmpty() True
Example 2: Checking if a non-empty DataFrame is empty
>>> df_non_empty = spark.createDataFrame(["a"], 'STRING') >>> df_non_empty.isEmpty() False
Example 3: Checking if a DataFrame with null values is empty
>>> df_nulls = spark.createDataFrame([(None, None)], 'a STRING, b INT') >>> df_nulls.isEmpty() False
Example 4: Checking if a DataFrame with no rows but with columns is empty
>>> df_no_rows = spark.createDataFrame([], 'id INT, value STRING') >>> df_no_rows.isEmpty() True