_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.Expr.... 

#  polars.Expr.map_batches  #

Expr.  map_batches  (

     _ function  :  Callable  [  [  Series  ]  ,  Series  |  Any  ]  _ , 
     _ return_dtype  :  PolarsDataType  |  [ None  ](https://docs.python.org/3/library/constants.html#None "\(in Python v3.12\)") =  None  _ , 
     _ *  _ , 
     _ agg_list  :  [ bool  ](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.12\)") =  False  _ , 
     _ is_elementwise  :  [ bool  ](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.12\)") =  False  _ , 
)  →  Self  [ [source]  ](https://github.com/pola-rs/polars/blob/main/py-
polars/polars/expr/expr.py#L4373-L4491) #

    

Apply a custom python function to a whole Series or sequence of Series.

The output of this custom function must be a Series (or a NumPy array, in
which case it will be automatically converted into a Series). If you want to
apply a custom function elementwise over single values, see [ ` map_elements()
` ](polars.Expr.map_elements.html#polars.Expr.map_elements
"polars.Expr.map_elements") . A reasonable use case for ` map  ` functions is
transforming the values represented by an expression using a third-party
library.

Warning

If you are looking to map a function over a window function or group_by
context, refer to [ ` map_elements()  `
](polars.Expr.map_elements.html#polars.Expr.map_elements
"polars.Expr.map_elements") instead. Read more in [ the book
](https://docs.pola.rs/user-guide/expressions/user-defined-functions) .

Parameters  :

    

**function**

    

Lambda/function to apply.

**return_dtype**

    

Dtype of the output Series. If not set, the dtype will be inferred based on
the first non-null value that is returned by the function.

**is_elementwise**

    

If set to true this can run in the streaming engine, but may yield incorrect
results in group-by. Ensure you know what you are doing!

**agg_list**

    

Aggregate the values of the expression into a list before applying the
function. This parameter only works in a group-by context. The function will
be invoked only once on a list of groups, rather than once per group.

Warning

If ` return_dtype  ` is not provided, this may lead to unexpected results. We
allow this, but it is considered a bug in the user’s query.

See also

[ ` map_elements  ` ](polars.Expr.map_elements.html#polars.Expr.map_elements
"polars.Expr.map_elements")

    
[ ` replace  ` ](polars.Expr.replace.html#polars.