datawrangler.zoo.polars_dataframe

datawrangler.zoo.polars_dataframe.is_polars_dataframe(x)[source]

Determine if an object is a Polars DataFrame.

Parameters

xobject

The object to check

Returns

bool

True if the object is a Polars DataFrame, False otherwise

datawrangler.zoo.polars_dataframe.is_polars_lazyframe(x)[source]

Determine if an object is a Polars LazyFrame.

Parameters

xobject

The object to check

Returns

bool

True if the object is a Polars LazyFrame, False otherwise

datawrangler.zoo.polars_dataframe.wrangle_polars_dataframe(data, return_model=False, **kwargs)[source]

Wrangle a Polars DataFrame.

This function accepts Polars DataFrames and LazyFrames and applies any specified transformations while preserving the Polars format.

Parameters

datapolars.DataFrame or polars.LazyFrame

The Polars DataFrame to wrangle

return_modelbool, optional

If True, return a function for transforming DataFrames along with the wrangled DataFrame. Default: False

**kwargsdict

Additional keyword arguments passed to the wrangling model

Returns

polars.DataFrame or tuple

The wrangled Polars DataFrame (if return_model is False), or a tuple of (DataFrame, model) if return_model is True

datawrangler.zoo.polars_dataframe.create_polars_dataframe(data, columns=None)[source]

Create a Polars DataFrame from various data types.

Parameters

dataarray-like, dict, or scalar

The data to convert to a Polars DataFrame

columnslist of str, optional

Column names for the DataFrame

Returns

polars.DataFrame

The created Polars DataFrame

datawrangler.zoo.polars_dataframe.pandas_to_polars(df)[source]

Convert a pandas DataFrame to a Polars DataFrame.

Parameters

dfpandas.DataFrame

The pandas DataFrame to convert

Returns

polars.DataFrame

The converted Polars DataFrame

datawrangler.zoo.polars_dataframe.polars_to_pandas(df)[source]

Convert a Polars DataFrame to a pandas DataFrame.

Parameters

dfpolars.DataFrame or polars.LazyFrame

The Polars DataFrame to convert

Returns

pandas.DataFrame

The converted pandas DataFrame