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)
  * __
  * [ Binary ](../binary.html)
  * polars.Expr.... 

#  polars.Expr.bin.contains  #

Expr.bin.  contains  (  _ literal  :  IntoExpr  _ )  →  Expr  [ [source]
](https://github.com/pola-rs/polars/blob/main/py-
polars/polars/expr/binary.py#L21-L66) #

    

Check if binaries in Series contain a binary substring.

Parameters  :

    

**literal**

    

The binary substring to look for

Returns  :

    

Expr

    

Expression of data type ` Boolean  ` .

See also

[ ` starts_with  `
](polars.Expr.bin.starts_with.html#polars.Expr.bin.starts_with
"polars.Expr.bin.starts_with")

    

Check if the binary substring exists at the start

[ ` ends_with  ` ](polars.Expr.bin.ends_with.html#polars.Expr.bin.ends_with
"polars.Expr.bin.ends_with")

    

Check if the binary substring exists at the end

Examples

    
    
    >>> colors = pl.DataFrame(
    ...     {
    ...         "name": ["black", "yellow", "blue"],
    ...         "code": [b"\x00\x00\x00", b"\xff\xff\x00", b"\x00\x00\xff"],
    ...         "lit": [b"\x00", b"\xff\x00", b"\xff\xff"],
    ...     }
    ... )
    >>> colors.select(
    ...     "name",
    ...     pl.col("code").bin.contains(b"\xff").alias("contains_with_lit"),
    ...     pl.col("code").bin.contains(pl.col("lit")).alias("contains_with_expr"),
    ... )
    shape: (3, 3)
    ┌────────┬───────────────────┬────────────────────┐
    │ name   ┆ contains_with_lit ┆ contains_with_expr │
    │ ---    ┆ ---               ┆ ---                │
    │ str    ┆ bool              ┆ bool               │
    ╞════════╪═══════════════════╪════════════════════╡
    │ black  ┆ false             ┆ true               │
    │ yellow ┆ true              ┆ true               │
    │ blue   ┆ true              ┆ false              │
    └────────┴───────────────────┴────────────────────┘
    

[ __ previous  Binary  ](../binary.html "previous page") [ next
polars.Expr.bin.decode  __ ](polars.Expr.bin.decode.html "next page")

__ On this page

  * ` Expr.bin.contains()  `

© 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.