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

#  polars.Expr.apply  #

Expr.  apply  (

     _ function  :  Callable  [  [  Series  ]  ,  Series  ]  |  Callable  [  [  Any  ]  ,  Any  ]  _ , 
     _ return_dtype  :  PolarsDataType  |  [ None  ](https://docs.python.org/3/library/constants.html#None "\(in Python v3.12\)") =  None  _ , 
     _ *  _ , 
     _ skip_nulls  :  [ bool  ](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.12\)") =  True  _ , 
     _ pass_name  :  [ bool  ](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.12\)") =  False  _ , 
     _ strategy  :  MapElementsStrategy  =  'thread_local'  _ , 
)  →  Self  [ [source]  ](https://github.com/pola-rs/polars/blob/main/py-
polars/polars/expr/expr.py#L9898-L9945) #

    

Apply a custom/user-defined function (UDF) in a GroupBy or Projection context.

Deprecated since version 0.19.0:  This method has been renamed to [ `
Expr.map_elements()  `
](polars.Expr.map_elements.html#polars.Expr.map_elements
"polars.Expr.map_elements") .

Parameters  :

    

**function**

    

Lambda/ function to apply.

**return_dtype**

    

Dtype of the output Series. If not set, the dtype will be ` polars.Unknown  `
.

**skip_nulls**

    

Don’t apply the function over values that contain nulls. This is faster.

**pass_name**

    

Pass the Series name to the custom function This is more expensive.

**strategy** {‘thread_local’, ‘threading’}

    

This functionality is in ` alpha  ` stage. This may be removed /changed
without it being considered a breaking change.

  * ‘thread_local’: run the python function on a single thread. 

  * ‘threading’: run the python function on separate threads. Use with care as this can slow performance. This might only speed up your code if the amount of work per element is significant and the python function releases the GIL (e.g. via calling a c function) 

[ __ previous  polars.zeros  ](polars.zeros.html "previous page") [ next
polars.Expr.head  __ ](polars.Expr.head.html "next page")

__ On this page

  * ` Expr.apply()  `

© Copyright 2020, Ritchie Vink.  

Created using [ Sphinx ](https://www.sphinx-doc.org/) 7.2.4.  

Built with the [ PyData Sphinx Theme ](https://pydata-sphinx-
theme.readthedocs.io/en/stable/index.html) 0.14.1.