class_docstr: Namespace for bin related expressions.
class_docstr_tok: ["Namespace","for","bin","related","expressions","."]
docstr: Encode a value using the provided encoding.
  
  Parameters
  ----------
  encoding : {'hex', 'base64'}
      The encoding to use.
  
  Returns
  -------
  Expr
      Expression of data type :class:`String` with values encoded using provided
      encoding.
  
  Examples
  --------
  >>> colors = pl.DataFrame(
  ...     {
  ...         "name": ["black", "yellow", "blue"],
  ...         "code": [b"\x00\x00\x00", b"\xff\xff\x00", b"\x00\x00\xff"],
  ...     }
  ... )
  >>> colors.with_columns(
  ...     pl.col("code").bin.encode("hex").alias("code_encoded_hex"),
  ... )
  shape: (3, 3)
  ┌────────┬───────────────┬──────────────────┐
  │ name   ┆ code          ┆ code_encoded_hex │
  │ ---    ┆ ---           ┆ ---              │
  │ str    ┆ binary        ┆ str              │
  ╞════════╪═══════════════╪══════════════════╡
  │ black  ┆ [binary data] ┆ 000000           │
  │ yellow ┆ [binary data] ┆ ffff00           │
  │ blue   ┆ [binary data] ┆ 0000ff           │
  └────────┴───────────────┴──────────────────┘
docstr_tok: ["Encode","a","value","using","the","provided","encoding",".","Parameters","--","--","--","--","--","encoding",":","{","'hex","'",",","'base64","'","}","The","encoding","to","use",".","Returns","--","--","--","-","Expr","Expression","of","data","type",":","class",":","`","String","`","with","values","encoded","using","provided","encoding",".","Examples","--","--","--","--",">",">",">","colors","=","pl.DataFrame","(","...","{","...","``","name","''",":","[","``","black","''",",","``","yellow","''",",","``","blue","''","]",",","...","``","code","''",":","[","b","''","\\x00\\x00\\x00","''",",","b","''","\\xff\\xff\\x00","''",",","b","''","\\x00\\x00\\xff","''","]",",","...","}","...",")",">",">",">","colors.with_columns","(","...","pl.col","(","``","code","''",")",".bin.encode","(","``","hex","''",")",".alias","(","``","code_encoded_hex","''",")",",","...",")","shape",":","(","3",",","3",")","\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510","\u2502","name","\u2506","code","\u2506","code_encoded_hex","\u2502","\u2502","--","-","\u2506","--","-","\u2506","--","-","\u2502","\u2502","str","\u2506","binary","\u2506","str","\u2502","\u255e\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2561","\u2502","black","\u2506","[","binary","data","]","\u2506","000000","\u2502","\u2502","yellow","\u2506","[","binary","data","]","\u2506","ffff00","\u2502","\u2502","blue","\u2506","[","binary","data","]","\u2506","0000ff","\u2502","\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"]
code: def encode(self, encoding: TransferEncoding) -> Expr:
      r"""
      Encode a value using the provided encoding.
  
      Parameters
      ----------
      encoding : {'hex', 'base64'}
          The encoding to use.
  
      Returns
      -------
      Expr
          Expression of data type :class:`String` with values encoded using provided
          encoding.
  
      Examples
      --------
      >>> colors = pl.DataFrame(
      ...     {
      ...         "name": ["black", "yellow", "blue"],
      ...         "code": [b"\x00\x00\x00", b"\xff\xff\x00", b"\x00\x00\xff"],
      ...     }
      ... )
      >>> colors.with_columns(
      ...     pl.col("code").bin.encode("hex").alias("code_encoded_hex"),
      ... )
      shape: (3, 3)
      ┌────────┬───────────────┬──────────────────┐
      │ name   ┆ code          ┆ code_encoded_hex │
      │ ---    ┆ ---           ┆ ---              │
      │ str    ┆ binary        ┆ str              │
      ╞════════╪═══════════════╪══════════════════╡
      │ black  ┆ [binary data] ┆ 000000           │
      │ yellow ┆ [binary data] ┆ ffff00           │
      │ blue   ┆ [binary data] ┆ 0000ff           │
      └────────┴───────────────┴──────────────────┘
  
      """
      if encoding == "hex":
          return wrap_expr(self._pyexpr.bin_hex_encode())
      elif encoding == "base64":
          return wrap_expr(self._pyexpr.bin_base64_encode())
      else:
          raise ValueError(
              f"`encoding` must be one of {{'hex', 'base64'}}, got {encoding!r}"
          )
  
file_path: polars/py-polars/polars/expr/binary.py
imports: from __future__ import annotations
  from typing import TYPE_CHECKING
  from polars.utils._parse_expr_input import parse_as_expression
  from polars.utils._wrap import wrap_expr
label_desc: Use image node_id 6 for calling the ExprBinaryNameSpace obj's underlying member method code with example usage: obj.encode(encoding) and returns: wrap_expr, wrap_expr