ing.assert_frame_equal.html)
    * [ polars.testing.assert_frame_not_equal ](../../api/polars.testing.assert_frame_not_equal.html)
    * [ polars.testing.assert_series_equal ](../../api/polars.testing.assert_series_equal.html)
    * [ polars.testing.assert_series_not_equal ](../../api/polars.testing.assert_series_not_equal.html)
    * [ polars.testing.parametric.dataframes ](../../api/polars.testing.parametric.dataframes.html)
    * [ polars.testing.parametric.series ](../../api/polars.testing.parametric.series.html)
    * [ polars.testing.parametric.column ](../../api/polars.testing.parametric.column.html)
    * [ polars.testing.parametric.columns ](../../api/polars.testing.parametric.columns.html)
    * [ polars.testing.parametric.create_list_strategy ](../../api/polars.testing.parametric.create_list_strategy.html)
    * [ polars.testing.parametric.load_profile ](../../api/polars.testing.parametric.load_profile.html)
    * [ polars.testing.parametric.set_profile ](../../api/polars.testing.parametric.set_profile.html)

  * [ Metadata ](../../metadata.html) __
    * [ polars.build_info ](../../api/polars.build_info.html)
    * [ polars.get_index_type ](../../api/polars.get_index_type.html)
    * [ polars.show_versions ](../../api/polars.show_versions.html)
    * [ polars.thread_pool_size ](../../api/polars.thread_pool_size.html)
    * [ polars.threadpool_size ](../../api/polars.threadpool_size.html)

  * [ __ ](../../../index.html)
  * [ Python API reference ](../../index.html)
  * __
  * [ Functions ](../functions.html)
  * polars.struct 

#  polars.struct  #

polars.  struct  (

     _ *  exprs  :  IntoExpr  |  Iterable  [  IntoExpr  ]  _ , 
     _ schema  :  SchemaDict  |  [ None  ](https://docs.python.org/3/library/constants.html#None "\(in Python v3.12\)") =  None  _ , 
     _ eager  :  [ bool  ](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.12\)") =  False  _ , 
     _ **  named_exprs  :  IntoExpr  _ , 
)  →  Expr  |  Series  [ [source]  ](https://github.com/pola-rs/polars/blob/main/py-polars/polars/functions/as_datatype.py#L468-L549) # 
    

Collect columns into a struct column.

Parameters  :

    

***exprs**

    

Column(s) to collect into a struct column, specified as positional arguments.
Accepts expression input. Strings are parsed as column names, other non-
expression inputs are parsed as literals.

**schema**

    

Optional schema that explicitly defines the struct field dtypes. If no columns
or expressions are provided, schema keys are used to define columns.

**eager**

    

Evaluate immediately and return a ` Series  ` . If set to ` False  `
(default), return an expression instead.

****named_exprs**

    

Additional columns to collect into the struct column, specified as keyword
arguments. The columns will be renamed to the keyword used.

Examples

Collect all columns of a dataframe into a struct by passing ` pl.all()  ` .

    
    
    >>> df = pl.DataFrame(
    ...     {
    ...         "int": [1, 2],
    ...         "str": ["a", "b"],
    ...         "bool": [True, None],
    ...         "list": [[1, 2], [3]],
    ...     }
    ... )
    >>> df.select(pl.struct(pl.all()).alias("my_struct"))
    shape: (2, 1)
    ┌─────────────────────┐
    │ my_struct           │
    │ ---                 │
    │ struct[4]           │
    ╞═════════════════════╡
    │ {1,"a",true,[1, 2]} │
    │ {2,"b",null,[3]}    │
    └─────────────────────┘
    

Collect selected columns into a struct by either passing a list of columns, or
by specifying each column as a positional argument.

    
    
    >>> df.select(pl.struct("int", False).alias("my_struct"))
    shape: (2, 1)
    ┌───────────┐
    │ my_struct │
    │ ---       │
    │ struct[2] │
    ╞═══════════╡
    │ {1,false} │
    │ {2,false} │
    └───────────┘
    

Use keyword arguments to easily name each struct field.

    
    
    >>> df.select(pl.struct(p="int", q="bool").alias("my_struct")).schema
    OrderedDict({'my_struct': Struct({