polars.testing.parametric.columns#

polars.testing.parametric.columns(
cols: int | Sequence[str] | None = None,
*,
dtype: OneOrMoreDataTypes | None = None,
min_cols: int = 0,
max_cols: int = 5,
unique: bool = False,
) list[column][source]#

Define multiple columns for use with the @dataframes strategy.

Deprecated since version 0.20.26: Use column instead in conjunction with a list comprehension.

Generate a fixed sequence of column objects suitable for passing to the @dataframes strategy, or using standalone (note that this function is not itself a strategy).

Parameters:
cols{int, [str]}, optional

integer number of cols to create, or explicit list of column names. if omitted a random number of columns (between mincol and max_cols) are created.

dtypePolarsDataType, optional

a single dtype for all cols, or list of dtypes (the same length as cols). if omitted, each generated column is assigned a random dtype.

min_colsint, optional

if not passing an exact size, can set a minimum here (defaults to 0).

max_colsint, optional

if not passing an exact size, can set a maximum value here (defaults to MAX_COLS).

uniquebool, optional

indicate if the values generated for these columns should be unique (per-column).

Notes

Additional control is available by creating a sequence of columns explicitly, using the column class (an especially useful option is to override the default data-generating strategy for a given col/dtype).

Examples

>>> from polars.testing.parametric import columns, dataframes
>>> from hypothesis import given
>>> @given(dataframes(columns(["x", "y", "z"], unique=True)))  
... def test_unique_xyz(df: pl.DataFrame) -> None:
...     assert_something(df)