o
    ¹­§ißS  ã                   @  sŠ   d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ er<d dlmZmZ d dlmZmZmZmZmZ G d	d
„ d
ƒZdS )é    )Úannotations)ÚTYPE_CHECKING)Úparse_into_expression)Úscale_bytes)Ú	wrap_expr)Úparse_into_datatype_expr)ÚDataTypeExprÚExpr)Ú
EndiannessÚIntoExprÚPolarsDataTypeÚSizeUnitÚTransferEncodingc                   @  s¨   e Zd ZdZdZd=dd„Zd>dd„Zd?dd„Zd@dd„ZddœdAdd„Z	dBdd„Z
dCdDd d!„Zd"d#œdEd(d)„Z	*dFdGd/d0„ZdHdId3d4„ZdHdId5d6„Zd7d8œdJd;d<„Zd*S )KÚExprBinaryNameSpacez&Namespace for bin related expressions.ÚbinÚexprr	   ÚreturnÚNonec                 C  s   |j | _ d S ©N)Ú_pyexpr)Úselfr   © r   úI/home/app/Keep/.python/lib/python3.10/site-packages/polars/expr/binary.pyÚ__init__   s   zExprBinaryNameSpace.__init__Úliteralr   c                 C  ó   t |dd}t| j |¡ƒS )u€  
        Check if binaries in Series contain a binary substring.

        Parameters
        ----------
        literal
            The binary substring to look for

        Returns
        -------
        Expr
            Expression of data type :class:`Boolean`.

        See Also
        --------
        starts_with : Check if the binary substring exists at the start
        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              â”‚
        â””â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”˜
        T©Z
str_as_lit)r   r   r   Zbin_contains)r   r   Zliteral_pyexprr   r   r   Úcontains   ó   ,zExprBinaryNameSpace.containsÚsuffixc                 C  r   )uñ  
        Check if string values end with a binary substring.

        Parameters
        ----------
        suffix
            Suffix substring.

        Returns
        -------
        Expr
            Expression of data type :class:`Boolean`.

        See Also
        --------
        starts_with : Check if the binary substring exists at the start
        contains : Check if the binary substring exists anywhere

        Examples
        --------
        >>> colors = pl.DataFrame(
        ...     {
        ...         "name": ["black", "yellow", "blue"],
        ...         "code": [b"\x00\x00\x00", b"\xff\xff\x00", b"\x00\x00\xff"],
        ...         "suffix": [b"\x00", b"\xff\x00", b"\x00\x00"],
        ...     }
        ... )
        >>> colors.select(
        ...     "name",
        ...     pl.col("code").bin.ends_with(b"\xff").alias("ends_with_lit"),
        ...     pl.col("code").bin.ends_with(pl.col("suffix")).alias("ends_with_expr"),
        ... )
        shape: (3, 3)
        â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”
        â”‚ name   â”† ends_with_lit â”† ends_with_expr â”‚
        â”‚ ---    â”† ---           â”† ---            â”‚
        â”‚ str    â”† bool          â”† bool           â”‚
        â•žâ•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•¡
        â”‚ black  â”† false         â”† true           â”‚
        â”‚ yellow â”† false         â”† true           â”‚
        â”‚ blue   â”† true          â”† false          â”‚
        â””â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”˜
        Tr   )r   r   r   Zbin_ends_with)r   r   Zsuffix_pyexprr   r   r   Ú	ends_withL   r   zExprBinaryNameSpace.ends_withÚprefixc                 C  r   )uN  
        Check if values start with a binary substring.

        Parameters
        ----------
        prefix
            Prefix substring.

        Returns
        -------
        Expr
            Expression of data type :class:`Boolean`.

        See Also
        --------
        ends_with : Check if the binary substring exists at the end
        contains : Check if the binary substring exists anywhere

        Examples
        --------
        >>> colors = pl.DataFrame(
        ...     {
        ...         "name": ["black", "yellow", "blue"],
        ...         "code": [b"\x00\x00\x00", b"\xff\xff\x00", b"\x00\x00\xff"],
        ...         "prefix": [b"\x00", b"\xff\x00", b"\x00\x00"],
        ...     }
        ... )
        >>> colors.select(
        ...     "name",
        ...     pl.col("code").bin.starts_with(b"\xff").alias("starts_with_lit"),
        ...     pl.col("code")
        ...     .bin.starts_with(pl.col("prefix"))
        ...     .alias("starts_with_expr"),
        ... )
        shape: (3, 3)
        â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”
        â”‚ name   â”† starts_with_lit â”† starts_with_expr â”‚
        â”‚ ---    â”† ---             â”† ---              â”‚
        â”‚ str    â”† bool            â”† bool             â”‚
        â•žâ•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•¡
        â”‚ black  â”† false           â”† true             â”‚
        â”‚ yellow â”† true            â”† false            â”‚
        â”‚ blue   â”† false           â”† true             â”‚
        â””â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”˜
        Tr   )r   r   r   Zbin_starts_with)r   r!   Zprefix_pyexprr   r   r   Ústarts_with{   s   .zExprBinaryNameSpace.starts_withT)ÚstrictÚencodingr   r#   Úboolc                C  sB   |dkrt | j |¡ƒS |dkrt | j |¡ƒS d|›}t|ƒ‚)uç  
        Decode values using the provided encoding.

        Parameters
        ----------
        encoding : {'hex', 'base64'}
            The encoding to use.
        strict
            Raise an error if the underlying value cannot be decoded,
            otherwise mask out with a null value.

        Returns
        -------
        Expr
            Expression of data type :class:`Binary`.

        Examples
        --------
        >>> colors = pl.DataFrame(
        ...     {
        ...         "name": ["black", "yellow", "blue"],
        ...         "encoded": [b"000000", b"ffff00", b"0000ff"],
        ...     }
        ... )
        >>> colors.with_columns(
        ...     pl.col("encoded").bin.decode("hex").alias("code"),
        ... )
        shape: (3, 3)
        â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”
        â”‚ name   â”† encoded   â”† code            â”‚
        â”‚ ---    â”† ---       â”† ---             â”‚
        â”‚ str    â”† binary    â”† binary          â”‚
        â•žâ•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•¡
        â”‚ black  â”† b"000000" â”† b"\x00\x00\x00" â”‚
        â”‚ yellow â”† b"ffff00" â”† b"\xff\xff\x00" â”‚
        â”‚ blue   â”† b"0000ff" â”† b"\x00\x00\xff" â”‚
        â””â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”˜
        ÚhexÚbase64ú1`encoding` must be one of {'hex', 'base64'}, got )r   r   Zbin_hex_decodeZbin_base64_decodeÚ
ValueError)r   r$   r#   Úmsgr   r   r   Údecode¬   s   '
zExprBinaryNameSpace.decodec                 C  s>   |dkrt | j ¡ ƒS |dkrt | j ¡ ƒS d|›}t|ƒ‚)uS  
        Encode a value using the provided encoding.

        Parameters
        ----------
        encoding : {'hex', 'base64'}
            The encoding to use.

        Returns
        -------
        Expr
            Expression of data type :class:`Binary`.

        Examples
        --------
        >>> colors = pl.DataFrame(
        ...     {
        ...         "color": ["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("encoded"),
        ... )
        shape: (3, 3)
        â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”€â”€â”€â”
        â”‚ color  â”† code            â”† encoded â”‚
        â”‚ ---    â”† ---             â”† ---     â”‚
        â”‚ str    â”† binary          â”† str     â”‚
        â•žâ•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•â•â•â•¡
        â”‚ black  â”† b"\x00\x00\x00" â”† 000000  â”‚
        â”‚ yellow â”† b"\xff\xff\x00" â”† ffff00  â”‚
        â”‚ blue   â”† b"\x00\x00\xff" â”† 0000ff  â”‚
        â””â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”€â”€â”˜
        r&   r'   r(   )r   r   Zbin_hex_encodeZbin_base64_encoder)   )r   r$   r*   r   r   r   ÚencodeÛ   s   $
zExprBinaryNameSpace.encodeÚbÚunitr   c                 C  s   t | j ¡ ƒ}t||ƒ}|S )u™  
        Get the size of binary values in the given unit.

        Parameters
        ----------
        unit : {'b', 'kb', 'mb', 'gb', 'tb'}
            Scale the returned size to the given unit.

        Returns
        -------
        Expr
            Expression of data type :class:`UInt32` or `Float64`.

        Examples
        --------
        >>> from os import urandom
        >>> df = pl.DataFrame({"data": [urandom(n) for n in (512, 256, 1024)]})
        >>> df.with_columns(  # doctest: +IGNORE_RESULT
        ...     n_bytes=pl.col("data").bin.size(),
        ...     n_kilobytes=pl.col("data").bin.size("kb"),
        ... )
        shape: (4, 3)
        â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”
        â”‚ data                            â”† n_bytes â”† n_kilobytes â”‚
        â”‚ ---                             â”† ---     â”† ---         â”‚
        â”‚ binary                          â”† u32     â”† f64         â”‚
        â•žâ•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•â•â•â•â•â•â•â•¡
        â”‚ b"y?~B\x83\xf4V\x07\xd3\xfb\xbâ€¦ â”† 512     â”† 0.5         â”‚
        â”‚ b"\xee$4@f\xc14\x07\x8e\x88\x1â€¦ â”† 256     â”† 0.25        â”‚
        â”‚ b"\x80\xbd\xb9nEq;2\x99$\xf9\xâ€¦ â”† 1024    â”† 1.0         â”‚
        â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”˜
        )r   r   Zbin_size_bytesr   )r   r.   Úszr   r   r   Úsize  s   !
zExprBinaryNameSpace.sizeÚlittle)Ú
endiannessÚdtypeúPolarsDataType | DataTypeExprr2   r
   c                C  s   t |ƒ}t| j |j|¡ƒS )uA  
        Interpret bytes as another type.

        Supported types are numerical or temporal dtypes, or an ``Array`` of
        these dtypes.

        Parameters
        ----------
        dtype : PolarsDataType
            Which type to interpret binary column into.
        endianness : {"big", "little"}, optional
            Which endianness to use when interpreting bytes, by default "little".

        Returns
        -------
        Expr
            Expression of data type `dtype`.
            Note that rows of the binary array where the length does not match
            the size in bytes of the output array (number of items * byte size
            of item) will become NULL.

        Examples
        --------
        >>> df = pl.DataFrame({"data": [b"\x05\x00\x00\x00", b"\x10\x00\x01\x00"]})
        >>> df.with_columns(  # doctest: +IGNORE_RESULT
        ...     bin2int=pl.col("data").bin.reinterpret(
        ...         dtype=pl.Int32, endianness="little"
        ...     ),
        ... )
        shape: (2, 2)
        â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”€â”€â”€â”
        â”‚ data                â”† bin2int â”‚
        â”‚ ---                 â”† ---     â”‚
        â”‚ binary              â”† i32     â”‚
        â•žâ•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•â•â•â•¡
        â”‚ b"\x05\x00\x00\x00" â”† 5       â”‚
        â”‚ b"\x10\x00\x01\x00" â”† 65552   â”‚
        â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”€â”€â”˜
        )r   r   r   Zbin_reinterpretZ_pydatatype_expr)r   r3   r2   r   r   r   Úreinterpret,  s   *ÿzExprBinaryNameSpace.reinterpretNÚoffsetúint | IntoExprÚlengthúint | IntoExpr | Nonec                 C  s"   t |ƒ}t |ƒ}t| j ||¡ƒS )u   
        Slice the binary values.

        Parameters
        ----------
        offset
            Start index. Negative indexing is supported.
        length
            Length of the slice. If set to ``None`` (default), the slice is taken to the
            end of the value.

        Returns
        -------
        Expr
            Expression of data type :class:`Binary`.

        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.slice(1, 2).alias("sliced"),
        ... )
        shape: (3, 3)
        â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”
        â”‚ name   â”† code            â”† sliced      â”‚
        â”‚ ---    â”† ---             â”† ---         â”‚
        â”‚ str    â”† binary          â”† binary      â”‚
        â•žâ•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•â•â•â•â•â•â•â•¡
        â”‚ black  â”† b"\x00\x00\x00" â”† b"\x00\x00" â”‚
        â”‚ yellow â”† b"\xff\xff\x00" â”† b"\xff\x00" â”‚
        â”‚ blue   â”† b"\x00\x00\xff" â”† b"\x00\xff" â”‚
        â””â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”˜
        )r   r   r   Z	bin_slice)r   r6   r8   Zoffset_pyexprZlength_pyexprr   r   r   Úslice\  s   )zExprBinaryNameSpace.sliceé   Únc                 C  r   )uÐ  
        Take the first `n` bytes of the binary values.

        Parameters
        ----------
        n
            Length of the slice (integer or expression). Negative indexing is supported;
            see note (2) below.

        Returns
        -------
        Expr
            Expression of data type :class:`Binary`.

        Notes
        -----
        (1) A similar method exists for taking the last `n` bytes: :func:`tail`.
        (2) If `n` is negative, it is interpreted as "until the nth byte from the end",
            e.g., ``head(-3)`` returns all but the last three bytes.

        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.head(2).alias("head"),
        ... )
        shape: (3, 3)
        â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”
        â”‚ name   â”† code            â”† head        â”‚
        â”‚ ---    â”† ---             â”† ---         â”‚
        â”‚ str    â”† binary          â”† binary      â”‚
        â•žâ•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•â•â•â•â•â•â•â•¡
        â”‚ black  â”† b"\x00\x00\x00" â”† b"\x00\x00" â”‚
        â”‚ yellow â”† b"\xff\xff\x00" â”† b"\xff\xff" â”‚
        â”‚ blue   â”† b"\x00\x00\xff" â”† b"\x00\x00" â”‚
        â””â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”˜
        Fr   )r   r   r   Zbin_head©r   r<   Zn_pyexprr   r   r   Úhead‰  ó   +zExprBinaryNameSpace.headc                 C  r   )uÊ  
        Take the last `n` bytes of the binary values.

        Parameters
        ----------
        n
            Length of the slice (integer or expression). Negative indexing is supported;
            see note (2) below.

        Returns
        -------
        Expr
            Expression of data type :class:`Binary`.

        Notes
        -----
        (1) A similar method exists for taking the first `n` bytes: :func:`head`.
        (2) If `n` is negative, it is interpreted as "starting at the nth byte",
            e.g., ``tail(-3)`` returns all but the first three bytes.

        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.tail(2).alias("tail"),
        ... )
        shape: (3, 3)
        â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”
        â”‚ name   â”† code            â”† tail        â”‚
        â”‚ ---    â”† ---             â”† ---         â”‚
        â”‚ str    â”† binary          â”† binary      â”‚
        â•žâ•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•â•â•â•â•â•â•â•¡
        â”‚ black  â”† b"\x00\x00\x00" â”† b"\x00\x00" â”‚
        â”‚ yellow â”† b"\xff\xff\x00" â”† b"\xff\x00" â”‚
        â”‚ blue   â”† b"\x00\x00\xff" â”† b"\x00\xff" â”‚
        â””â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”˜
        Fr   )r   r   r   Zbin_tailr=   r   r   r   Útail·  r?   zExprBinaryNameSpace.tailF)Únull_on_oobÚindexrA   c                C  s   t |ƒ}t| j ||¡ƒS )uÌ  
        Get the byte value at the given index.

        For example, index `0` would return the first byte of every binary value
        and index `-1` would return the last byte of every binary value.
        If an index is out of bounds, it will return a `None`.

        Parameters
        ----------
        index
            Index to return per binary value
        null_on_oob
            Behavior if an index is out of bounds:

            * True -> set as null
            * False -> raise an error

        Examples
        --------
        >>> df = pl.DataFrame({"a": [b"\x01\x02\x03", b"", b"\x04\x05"]})
        >>> df.with_columns(get=pl.col("a").bin.get(0, null_on_oob=True))
        shape: (3, 2)
        â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”
        â”‚ a               â”† get  â”‚
        â”‚ ---             â”† ---  â”‚
        â”‚ binary          â”† u8   â”‚
        â•žâ•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•¡
        â”‚ b"\x01\x02\x03" â”† 1    â”‚
        â”‚ b""             â”† null â”‚
        â”‚ b"\x04\x05"     â”† 4    â”‚
        â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”˜
        )r   r   r   Zbin_get)r   rB   rA   Zindex_pyexprr   r   r   Úgetå  s   !zExprBinaryNameSpace.get)r   r	   r   r   )r   r   r   r	   )r   r   r   r	   )r!   r   r   r	   )r$   r   r#   r%   r   r	   )r$   r   r   r	   )r-   )r.   r   r   r	   )r3   r4   r2   r
   r   r	   r   )r6   r7   r8   r9   r   r	   )r;   )r<   r7   r   r	   )rB   r7   rA   r%   r   r	   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	_accessorr   r   r    r"   r+   r,   r0   r5   r:   r>   r@   rC   r   r   r   r   r      s"    


/
/1
/,&ÿ1ÿ-..r   N)Ú
__future__r   Útypingr   Zpolars._utils.parser   Zpolars._utils.variousr   Zpolars._utils.wrapr   Zpolars.datatypesr   Zpolarsr   r	   Zpolars._typingr
   r   r   r   r   r   r   r   r   r   Ú<module>   s    	