.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)
  * __
  * [ Window ](../window.html)
  * polars.Expr.over 

#  polars.Expr.over  #

Expr.  over  (

     _ expr  :  IntoExpr  |  Iterable  [  IntoExpr  ]  _ , 
     _ *  more_exprs  :  IntoExpr  _ , 
     _ mapping_strategy  :  WindowMappingStrategy  =  'group_to_rows'  _ , 
)  →  Self  [ [source]  ](https://github.com/pola-rs/polars/blob/main/py-
polars/polars/expr/expr.py#L3477-L3617) #

    

Compute expressions over the given groups.

This expression is similar to performing a group by aggregation and joining
the result back into the original DataFrame.

The outcome is similar to how [ window functions
](https://www.postgresql.org/docs/current/tutorial-window.html) work in
PostgreSQL.

Parameters  :

    

**expr**

    

Column(s) to group by. Accepts expression input. Strings are parsed as column
names.

***more_exprs**

    

Additional columns to group by, specified as positional arguments.

**mapping_strategy: {‘group_to_rows’, ‘join’, ‘explode’}**

    

  * group_to_rows 
    

If the aggregation results in multiple values, assign them back to their
position in the DataFrame. This can only be done if the group yields the same
elements before aggregation as after.

  * join 
    

Join the groups as ‘List<group_dtype>’ to the row positions. warning: this can
be memory intensive.

  * explode 
    

Explodes the grouped data into new rows, similar to the results of ` group_by
` \+ ` agg  ` \+ ` explode  ` . Sorting of the given groups is required if the
groups are not part of the window operation for the operation, otherwise the
result would not make sense. This operation changes the number of rows.

Examples

Pass the name of a column to compute the expression over that column.

    
    
    >>> df = pl.DataFrame(
    ...     {
    ...         "a": ["a", "a", "b", "b", "b"],
    ...         "b": [1, 2, 3, 5, 3],
    ...         "c": [5, 4, 3, 2, 1],
    ...     }
    ... )
    >>> df.with_columns(
    ...     pl.col("c").max().over("a").name.suffix("_max"),
    ... )
    shape: (5, 4)
    ┌─────┬─────┬─────┬───────┐
    │ a   ┆ b   ┆ c   ┆ c_max │
    │ --- ┆ --- ┆ --- ┆ ---   │
    │ str ┆ i64 ┆ i64 ┆ i64   │
    ╞═════╪═════╪═════╪═══════╡
    │ a   ┆ 1   ┆ 5   ┆ 5     │
    │ a   ┆ 2   ┆ 4   ┆ 5     │
    │ b   ┆ 3   ┆ 3   ┆ 3     │
    │ b   ┆ 5   ┆ 2   ┆ 3     │
    │ b   ┆ 3   ┆ 1   ┆ 3     │
    └─────┴─────┴─────┴───────┘
    

Expression input is supported.

    
    
    >>> df.with_columns(
    ...     pl.col("c").max().over(pl.col("