Schema.create_empty_if_none#
- classmethod Schema.create_empty_if_none( ) DataFrame[Self] | LazyFrame[Self][source]#
Impute
Noneinput with an empty, schema-compliant lazy or eager data frame or return the input as lazy or eager frame.- Parameters:
df – The data frame to check for
None. If it is notNone, it is returned as lazy or eager frame. Otherwise, a schema-compliant data or lazy frame with no rows is returned.lazy – Whether to return a lazy data frame. If
True, returns a lazy frame with thisSchema. Otherwise, returns an eager frame.
- Returns:
The given data frame
dfas lazy or eager frame, if it is notNone. An instance ofpolars.DataFrameorpolars.LazyFramewith this schema’s defined columns and their data types, but no rows, otherwise.