§
    q-PhÓ  ã                  óŒ   — d dl mZ d dlmZ d dlmZ erd dlmZ d dlm	Z	m
Z
mZmZmZ d dlmZ e G d„ d¦  «        ¦   «         Zd	S )
é    )Úannotations)ÚTYPE_CHECKING)Úexpr_dispatch)ÚSeries)Ú
EndiannessÚIntoExprÚPolarsDataTypeÚSizeUnitÚTransferEncoding)ÚPySeriesc                  ód   — e Zd ZdZdZd#d„Zd$d
„Zd%d„Zd&d„Zddœd'd„Z	d(d„Z
d)d*d„Zddœd+d!„Zd"S ),ÚBinaryNameSpacezSeries.bin namespace.ÚbinÚseriesr   ÚreturnÚNonec                ó   — |j         | _         d S )N)Ú_s)Úselfr   s     úT/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/polars/series/binary.pyÚ__init__zBinaryNameSpace.__init__   s   € Ø"œIˆŒˆˆó    Úliteralr   c                ó   — dS )a+  
        Check if binaries in Series contain a binary substring.

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

        Returns
        -------
        Series
            Series of data type :class:`Boolean`.

        Examples
        --------
        >>> s = pl.Series("colors", [b"\x00\x00\x00", b"\xff\xff\x00", b"\x00\x00\xff"])
        >>> s.bin.contains(b"\xff")
        shape: (3,)
        Series: 'colors' [bool]
        [
            false
            true
            true
        ]
        N© )r   r   s     r   ÚcontainszBinaryNameSpace.contains   ó   € € € r   Úsuffixc                ó   — dS )a¶  
        Check if string values end with a binary substring.

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

        Examples
        --------
        >>> s = pl.Series("colors", [b"\x00\x00\x00", b"\xff\xff\x00", b"\x00\x00\xff"])
        >>> s.bin.ends_with(b"\x00")
        shape: (3,)
        Series: 'colors' [bool]
        [
            true
            true
            false
        ]
        Nr   )r   r   s     r   Ú	ends_withzBinaryNameSpace.ends_with7   r   r   Úprefixc                ó   — dS )a³  
        Check if values start with a binary substring.

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

        Examples
        --------
        >>> s = pl.Series("colors", [b"\x00\x00\x00", b"\xff\xff\x00", b"\x00\x00\xff"])
        >>> s.bin.starts_with(b"\x00")
        shape: (3,)
        Series: 'colors' [bool]
        [
            true
            false
            true
        ]
        Nr   )r   r!   s     r   Ústarts_withzBinaryNameSpace.starts_withM   r   r   T)ÚstrictÚencodingr   r$   Úboolc               ó   — dS )a„  
        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
        -------
        Series
            Series of data type :class:`String`.

        Examples
        --------
        Decode values using hexadecimal encoding.

        >>> s = pl.Series("colors", [b"000000", b"ffff00", b"0000ff"])
        >>> s.bin.decode("hex")
        shape: (3,)
        Series: 'colors' [binary]
        [
            b"\x00\x00\x00"
            b"\xff\xff\x00"
            b"\x00\x00\xff"
        ]

        Decode values using Base64 encoding.

        >>> s = pl.Series("colors", [b"AAAA", b"//8A", b"AAD/"])
        >>> s.bin.decode("base64")
        shape: (3,)
        Series: 'colors' [binary]
        [
            b"\x00\x00\x00"
            b"\xff\xff\x00"
            b"\x00\x00\xff"
        ]

        Set `strict=False` to set invalid values to null instead of raising an error.

        >>> s = pl.Series("colors", [b"000000", b"ffff00", b"invalid_value"])
        >>> s.bin.decode("hex", strict=False)
        shape: (3,)
        Series: 'colors' [binary]
        [
            b"\x00\x00\x00"
            b"\xff\xff\x00"
            null
        ]
        Nr   )r   r%   r$   s      r   ÚdecodezBinaryNameSpace.decodec   r   r   c                ó   — dS )a1  
        Encode values using the provided encoding.

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

        Returns
        -------
        Series
            Series of data type :class:`String`.

        Examples
        --------
        Encode values using hexadecimal encoding.

        >>> s = pl.Series("colors", [b"\x00\x00\x00", b"\xff\xff\x00", b"\x00\x00\xff"])
        >>> s.bin.encode("hex")
        shape: (3,)
        Series: 'colors' [str]
        [
            "000000"
            "ffff00"
            "0000ff"
        ]

        Encode values using Base64 encoding.

        >>> s.bin.encode("base64")
        shape: (3,)
        Series: 'colors' [str]
        [
            "AAAA"
            "//8A"
            "AAD/"
        ]
        Nr   )r   r%   s     r   ÚencodezBinaryNameSpace.encode›   r   r   ÚbÚunitr
   c                ó   — dS )aì  
        Get the size of the binary values in a Series in the given unit.

        Returns
        -------
        Series
            Series of data type :class:`UInt32`.

        Examples
        --------
        >>> from os import urandom
        >>> s = pl.Series("data", [urandom(n) for n in (512, 256, 2560, 1024)])
        >>> s.bin.size("kb")
        shape: (4,)
        Series: 'data' [f64]
        [
            0.5
            0.25
            2.5
            1.0
        ]
        Nr   )r   r,   s     r   ÚsizezBinaryNameSpace.sizeÃ   r   r   Úlittle)Ú
endiannessÚdtyper	   r0   r   c               ó   — dS )a?  
        Interpret a buffer as a numerical polars type.

        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
        -------
        Series
            Series of data type `dtype`.
            Note that if binary array is too short value will be null.
            If binary array is too long, remainder will be ignored.

        Examples
        --------
        >>> s = pl.Series("data", [b"\x05\x00\x00\x00", b"\x10\x00\x01\x00"])
        >>> s.bin.reinterpret(dtype=pl.Int32, endianness="little")
        shape: (2,)
        Series: 'data' [i32]
        [
            5
            65552
        ]

        Nr   )r   r1   r0   s      r   ÚreinterpretzBinaryNameSpace.reinterpretÛ   r   r   N)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   )r1   r	   r0   r   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	_accessorr   r   r    r#   r(   r*   r.   r3   r   r   r   r   r      sè   € € € € € àÐà€Ið&ð &ð &ð &ðð ð ð ð6ð ð ð ð,ð ð ð ð, DHð 6ð 6ð 6ð 6ð 6ð 6ðp&ð &ð &ð &ðPð ð ð ð ð2 BJðð ð ð ð ð ð ð r   r   N)Ú
__future__r   Útypingr   Úpolars.series.utilsr   Úpolarsr   Úpolars._typingr   r   r	   r
   r   Úpolars.polarsr   r   r   r   r   ú<module>r?      s÷   ðØ "Ð "Ð "Ð "Ð "Ð "à  Ð  Ð  Ð  Ð  Ð  à -Ð -Ð -Ð -Ð -Ð -àð 	'ØÐÐÐÐÐðð ð ð ð ð ð ð ð ð ð ð ð ð ð 'Ð&Ð&Ð&Ð&Ð&ð ðfð fð fð fð fñ fô fñ „ðfð fð fr   