Ë
    	êñiu˜  ã                  óŒ   — 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 d dlmZ d d	lmZmZ  G d
„ d«      Zy)é    )Úannotations)ÚSequence)ÚTYPE_CHECKING)Ú	functions)Úparse_into_expression)Ú	wrap_expr)ÚCallable)ÚExpr)ÚIntoExprÚIntoExprColumnc                  ó†  — e Zd ZdZdZd.d„Zd/d„Z	 d0ddœ	 	 	 	 	 	 	 d1d„Zd2ddœd3d	„Zd2ddœd3d
„Z	d/d„Z
d/d„Zd/d„Zd4d5d„Zd4d5d„Zd/d„Zd/d„Zddœd6d„Zd/d„Zd/d„Zddœd7d„Zddœd7d„Zdddœd8d„Zd/d„Zd/d„Zd/d„Zddœd9d „Zd/d!„Zd/d"„Zddœd:d#„Zddd$œd;d%„Zdd&œd<d'„Zd=d(„Z 	 d0	 	 	 d>d)„Z!d4d?d*„Z"dd+œd@d,„Z#dAd-„Z$y)BÚExprArrayNameSpacez(Namespace for array related expressions.Úarrc                ó&   — |j                   | _         y ©N)Ú_pyexpr©ÚselfÚexprs     úS/var/www/pod-logistic/pod-ai/venv/lib/python3.12/site-packages/polars/expr/array.pyÚ__init__zExprArrayNameSpace.__init__   s   € Ø—|‘|ˆ�ó    c                óH   — t        | j                  j                  «       «      S )uò  
        Return the number of elements in each array.

        Examples
        --------
        >>> df = pl.DataFrame(
        ...     data={"a": [[1, 2], [4, 3]]},
        ...     schema={"a": pl.Array(pl.Int64, 2)},
        ... )
        >>> df.select(pl.col("a").arr.len())
        shape: (2, 1)
        ┌─────┐
        │ a   │
        │ --- │
        │ u32 │
        ╞═════╡
        │ 2   │
        │ 2   │
        └─────┘
        )r   r   Úarr_len©r   s    r   ÚlenzExprArrayNameSpace.len   ó   € ô* ˜Ÿ™×-Ñ-Ó/Ó0Ð0r   NF©Úas_arrayc               ó‚   — t        |«      }|�t        |«      nd}t        | j                  j                  |||«      «      S )uù  
        Slice every subarray.

        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 list.
        as_array
            Return result as a fixed-length `Array`, otherwise as a `List`.
            If true `length` and `offset` must be constant values.

        Examples
        --------
        >>> df = pl.DataFrame(
        ...     data={"a": [[1, 2], [4, 3]]},
        ...     schema={"a": pl.Array(pl.Int64, 2)},
        ... )
        >>> df.select(pl.col("a").arr.slice(0, 1))
        shape: (2, 1)
        ┌───────────┐
        │ a         │
        │ ---       │
        │ list[i64] │
        ╞═══════════╡
        │ [1]       │
        │ [4]       │
        └───────────┘
        >>> df = pl.DataFrame(
        ...     data={"a": [[1, 2], [4, 3]]},
        ...     schema={"a": pl.Array(pl.Int64, 2)},
        ... )
        >>> df.select(pl.col("a").arr.slice(0, 1, as_array=True))
        shape: (2, 1)
        ┌───────────────┐
        │ a             │
        │ ---           │
        │ array[i64, 1] │
        ╞═══════════════╡
        │ [1]           │
        │ [4]           │
        └───────────────┘
        N)r   r   r   Ú	arr_slice)r   ÚoffsetÚlengthr   Úoffset_pyexprÚlength_pyexprs         r   ÚslicezExprArrayNameSpace.slice0   s@   € ôh .¨fÓ5ˆØ9?Ð9KÔ-¨fÔ5ÐQUˆÜ˜Ÿ™×/Ñ/°¸}ÈhÓWÓXÐXr   c               ó*   — | j                  d||¬«      S )up  
        Get the first `n` elements of the sub-arrays.

        Parameters
        ----------
        n
            Number of values to return for each sublist.
        as_array
            Return result as a fixed-length `Array`, otherwise as a `List`.
            If true `n` must be a constant value.

        Examples
        --------
        >>> df = pl.DataFrame(
        ...     data={"a": [[1, 2], [4, 3]]},
        ...     schema={"a": pl.Array(pl.Int64, 2)},
        ... )
        >>> df.select(pl.col("a").arr.head(1))
        shape: (2, 1)
        ┌───────────┐
        │ a         │
        │ ---       │
        │ list[i64] │
        ╞═══════════╡
        │ [1]       │
        │ [4]       │
        └───────────┘
        >>> df = pl.DataFrame(
        ...     data={"a": [[1, 2], [4, 3]]},
        ...     schema={"a": pl.Array(pl.Int64, 2)},
        ... )
        >>> df.select(pl.col("a").arr.head(1, as_array=True))
        shape: (2, 1)
        ┌───────────────┐
        │ a             │
        │ ---           │
        │ array[i64, 1] │
        ╞═══════════════╡
        │ [1]           │
        │ [4]           │
        └───────────────┘
        r   r   )r&   )r   Únr   s      r   ÚheadzExprArrayNameSpace.headh   s   € ðV �z‰z˜!˜Q¨ˆzÓ2Ð2r   c               ób   — t        |«      }t        | j                  j                  ||«      «      S )un  
        Slice the last `n` values of every sublist.

        Parameters
        ----------
        n
            Number of values to return for each sublist.
        as_array
            Return result as a fixed-length `Array`, otherwise as a `List`.
            If true `n` must be a constant value.

        Examples
        --------
        >>> df = pl.DataFrame(
        ...     data={"a": [[1, 2], [4, 3]]},
        ...     schema={"a": pl.Array(pl.Int64, 2)},
        ... )
        >>> df.select(pl.col("a").arr.tail(1))
        shape: (2, 1)
        ┌───────────┐
        │ a         │
        │ ---       │
        │ list[i64] │
        ╞═══════════╡
        │ [2]       │
        │ [3]       │
        └───────────┘
        >>> df = pl.DataFrame(
        ...     data={"a": [[1, 2], [4, 3]]},
        ...     schema={"a": pl.Array(pl.Int64, 2)},
        ... )
        >>> df.select(pl.col("a").arr.tail(1, as_array=True))
        shape: (2, 1)
        ┌───────────────┐
        │ a             │
        │ ---           │
        │ array[i64, 1] │
        ╞═══════════════╡
        │ [2]           │
        │ [3]           │
        └───────────────┘
        )r   r   r   Úarr_tail)r   r(   r   Ún_pyexprs       r   ÚtailzExprArrayNameSpace.tail•   s+   € ôV )¨Ó+ˆÜ˜Ÿ™×.Ñ.¨x¸ÓBÓCÐCr   c                óH   — t        | j                  j                  «       «      S )uï  
        Compute the min values of the sub-arrays.

        Examples
        --------
        >>> df = pl.DataFrame(
        ...     data={"a": [[1, 2], [4, 3]]},
        ...     schema={"a": pl.Array(pl.Int64, 2)},
        ... )
        >>> df.select(pl.col("a").arr.min())
        shape: (2, 1)
        ┌─────┐
        │ a   │
        │ --- │
        │ i64 │
        ╞═════╡
        │ 1   │
        │ 3   │
        └─────┘
        )r   r   Úarr_minr   s    r   ÚminzExprArrayNameSpace.minÃ   r   r   c                óH   — t        | j                  j                  «       «      S )uï  
        Compute the max values of the sub-arrays.

        Examples
        --------
        >>> df = pl.DataFrame(
        ...     data={"a": [[1, 2], [4, 3]]},
        ...     schema={"a": pl.Array(pl.Int64, 2)},
        ... )
        >>> df.select(pl.col("a").arr.max())
        shape: (2, 1)
        ┌─────┐
        │ a   │
        │ --- │
        │ i64 │
        ╞═════╡
        │ 2   │
        │ 4   │
        └─────┘
        )r   r   Úarr_maxr   s    r   ÚmaxzExprArrayNameSpace.maxÚ   r   r   c                óH   — t        | j                  j                  «       «      S )uï  
        Compute the sum values of the sub-arrays.

        Examples
        --------
        >>> df = pl.DataFrame(
        ...     data={"a": [[1, 2], [4, 3]]},
        ...     schema={"a": pl.Array(pl.Int64, 2)},
        ... )
        >>> df.select(pl.col("a").arr.sum())
        shape: (2, 1)
        ┌─────┐
        │ a   │
        │ --- │
        │ i64 │
        ╞═════╡
        │ 3   │
        │ 7   │
        └─────┘
        )r   r   Úarr_sumr   s    r   ÚsumzExprArrayNameSpace.sumñ   r   r   c                óJ   — t        | j                  j                  |«      «      S )u<  
        Compute the std of the values of the sub-arrays.

        Examples
        --------
        >>> df = pl.DataFrame(
        ...     data={"a": [[1, 2], [4, 3]]},
        ...     schema={"a": pl.Array(pl.Int64, 2)},
        ... )
        >>> df.select(pl.col("a").arr.std())
        shape: (2, 1)
        ┌──────────┐
        │ a        │
        │ ---      │
        │ f64      │
        ╞══════════╡
        │ 0.707107 │
        │ 0.707107 │
        └──────────┘
        )r   r   Úarr_std©r   Úddofs     r   ÚstdzExprArrayNameSpace.std  ó   € ô* ˜Ÿ™×-Ñ-¨dÓ3Ó4Ð4r   c                óJ   — t        | j                  j                  |«      «      S )uö  
        Compute the var of the values of the sub-arrays.

        Examples
        --------
        >>> df = pl.DataFrame(
        ...     data={"a": [[1, 2], [4, 3]]},
        ...     schema={"a": pl.Array(pl.Int64, 2)},
        ... )
        >>> df.select(pl.col("a").arr.var())
        shape: (2, 1)
        ┌─────┐
        │ a   │
        │ --- │
        │ f64 │
        ╞═════╡
        │ 0.5 │
        │ 0.5 │
        └─────┘
        )r   r   Úarr_varr9   s     r   ÚvarzExprArrayNameSpace.var  r<   r   c                óH   — t        | j                  j                  «       «      S )uÿ  
        Compute the mean of the values of the sub-arrays.

        Examples
        --------
        >>> df = pl.DataFrame(
        ...     data={"a": [[1, 2, 3], [1, 1, 16]]},
        ...     schema={"a": pl.Array(pl.Int64, 3)},
        ... )
        >>> df.select(pl.col("a").arr.mean())
        shape: (2, 1)
        ┌─────┐
        │ a   │
        │ --- │
        │ f64 │
        ╞═════╡
        │ 2.0 │
        │ 6.0 │
        └─────┘
        )r   r   Úarr_meanr   s    r   ÚmeanzExprArrayNameSpace.mean6  s   € ô* ˜Ÿ™×.Ñ.Ó0Ó1Ð1r   c                óH   — t        | j                  j                  «       «      S )uü  
        Compute the median of the values of the sub-arrays.

        Examples
        --------
        >>> df = pl.DataFrame(
        ...     data={"a": [[1, 2], [4, 3]]},
        ...     schema={"a": pl.Array(pl.Int64, 2)},
        ... )
        >>> df.select(pl.col("a").arr.median())
        shape: (2, 1)
        ┌─────┐
        │ a   │
        │ --- │
        │ f64 │
        ╞═════╡
        │ 1.5 │
        │ 3.5 │
        └─────┘
        )r   r   Ú
arr_medianr   s    r   ÚmedianzExprArrayNameSpace.medianM  s   € ô* ˜Ÿ™×0Ñ0Ó2Ó3Ð3r   )Úmaintain_orderc               óJ   — t        | j                  j                  |«      «      S )uÇ  
        Get the unique/distinct values in the array.

        Parameters
        ----------
        maintain_order
            Maintain order of data. This requires more work.

        Examples
        --------
        >>> df = pl.DataFrame(
        ...     {
        ...         "a": [[1, 1, 2]],
        ...     },
        ...     schema={"a": pl.Array(pl.Int64, 3)},
        ... )
        >>> df.select(pl.col("a").arr.unique())
        shape: (1, 1)
        ┌───────────┐
        │ a         │
        │ ---       │
        │ list[i64] │
        ╞═══════════╡
        │ [1, 2]    │
        └───────────┘
        )r   r   Ú
arr_unique)r   rF   s     r   ÚuniquezExprArrayNameSpace.uniqued  s   € ô6 ˜Ÿ™×0Ñ0°Ó@ÓAÐAr   c                óH   — t        | j                  j                  «       «      S )uh  
        Count the number of unique values in every sub-arrays.

        Examples
        --------
        >>> df = pl.DataFrame(
        ...     {
        ...         "a": [[1, 1, 2], [2, 3, 4]],
        ...     },
        ...     schema={"a": pl.Array(pl.Int64, 3)},
        ... )
        >>> df.with_columns(n_unique=pl.col("a").arr.n_unique())
        shape: (2, 2)
        ┌───────────────┬──────────┐
        │ a             ┆ n_unique │
        │ ---           ┆ ---      │
        │ array[i64, 3] ┆ u32      │
        ╞═══════════════╪══════════╡
        │ [1, 1, 2]     ┆ 2        │
        │ [2, 3, 4]     ┆ 3        │
        └───────────────┴──────────┘
        )r   r   Úarr_n_uniquer   s    r   Ún_uniquezExprArrayNameSpace.n_unique�  s   € ô. ˜Ÿ™×2Ñ2Ó4Ó5Ð5r   c                óH   — t        | j                  j                  «       «      S )u¹  
        Convert an Array column into a List column with the same inner data type.

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

        Examples
        --------
        >>> df = pl.DataFrame(
        ...     data={"a": [[1, 2], [3, 4]]},
        ...     schema={"a": pl.Array(pl.Int8, 2)},
        ... )
        >>> df.select(pl.col("a").arr.to_list())
        shape: (2, 1)
        ┌──────────┐
        │ a        │
        │ ---      │
        │ list[i8] │
        ╞══════════╡
        │ [1, 2]   │
        │ [3, 4]   │
        └──────────┘
        )r   r   Úarr_to_listr   s    r   Úto_listzExprArrayNameSpace.to_listš  s   € ô4 ˜Ÿ™×1Ñ1Ó3Ó4Ð4r   T©Úignore_nullsc               óh   — | j                  t        j                  «       j                  |¬«      «      S )uT  
        Evaluate whether any boolean value is true for every subarray.

        Parameters
        ----------
        ignore_nulls
            * If set to `True` (default), null values are ignored. If there
              are no non-null values, the output is `False`.
            * If set to `False`, `Kleene logic`_ is used to deal with nulls:
              if the column contains any null values and no `True` values,
              the output is null.

            .. _Kleene logic: https://en.wikipedia.org/wiki/Three-valued_logic

        Examples
        --------
        >>> df = pl.DataFrame(
        ...     data={
        ...         "a": [
        ...             [True, True],
        ...             [False, True],
        ...             [False, False],
        ...             [None, None],
        ...             None,
        ...         ]
        ...     },
        ...     schema={"a": pl.Array(pl.Boolean, 2)},
        ... )
        >>> df.with_columns(any=pl.col("a").arr.any())
        shape: (5, 2)
        ┌────────────────┬───────┐
        │ a              ┆ any   │
        │ ---            ┆ ---   │
        │ array[bool, 2] ┆ bool  │
        ╞════════════════╪═══════╡
        │ [true, true]   ┆ true  │
        │ [false, true]  ┆ true  │
        │ [false, false] ┆ false │
        │ [null, null]   ┆ false │
        │ null           ┆ null  │
        └────────────────┴───────┘
        rP   )ÚaggÚFÚelementÚany©r   rQ   s     r   rV   zExprArrayNameSpace.any¶  ó%   € ðV �x‰xœŸ	™	›Ÿ™°\˜ÓBÓCÐCr   c               óh   — | j                  t        j                  «       j                  |¬«      «      S )uV  
        Evaluate whether all boolean values are true for every subarray.

        Parameters
        ----------
        ignore_nulls
            * If set to `True` (default), null values are ignored. If there
              are no non-null values, the output is `True`.
            * If set to `False`, `Kleene logic`_ is used to deal with nulls:
              if the column contains any null values and no `False` values,
              the output is null.

            .. _Kleene logic: https://en.wikipedia.org/wiki/Three-valued_logic

        Examples
        --------
        >>> df = pl.DataFrame(
        ...     data={
        ...         "a": [
        ...             [True, True],
        ...             [False, True],
        ...             [False, False],
        ...             [None, None],
        ...             None,
        ...         ]
        ...     },
        ...     schema={"a": pl.Array(pl.Boolean, 2)},
        ... )
        >>> df.with_columns(all=pl.col("a").arr.all())
        shape: (5, 2)
        ┌────────────────┬───────┐
        │ a              ┆ all   │
        │ ---            ┆ ---   │
        │ array[bool, 2] ┆ bool  │
        ╞════════════════╪═══════╡
        │ [true, true]   ┆ true  │
        │ [false, true]  ┆ false │
        │ [false, false] ┆ false │
        │ [null, null]   ┆ true  │
        │ null           ┆ null  │
        └────────────────┴───────┘
        rP   )rS   rT   rU   ÚallrW   s     r   rZ   zExprArrayNameSpace.allã  rX   r   )Ú
descendingÚ
nulls_lastc               óL   — t        | j                  j                  ||«      «      S )u¸  
        Sort the arrays in this column.

        Parameters
        ----------
        descending
            Sort in descending order.
        nulls_last
            Place null values last.

        Examples
        --------
        >>> df = pl.DataFrame(
        ...     {
        ...         "a": [[3, 2, 1], [9, 1, 2]],
        ...     },
        ...     schema={"a": pl.Array(pl.Int64, 3)},
        ... )
        >>> df.with_columns(sort=pl.col("a").arr.sort())
        shape: (2, 2)
        ┌───────────────┬───────────────┐
        │ a             ┆ sort          │
        │ ---           ┆ ---           │
        │ array[i64, 3] ┆ array[i64, 3] │
        ╞═══════════════╪═══════════════╡
        │ [3, 2, 1]     ┆ [1, 2, 3]     │
        │ [9, 1, 2]     ┆ [1, 2, 9]     │
        └───────────────┴───────────────┘
        >>> df.with_columns(sort=pl.col("a").arr.sort(descending=True))
        shape: (2, 2)
        ┌───────────────┬───────────────┐
        │ a             ┆ sort          │
        │ ---           ┆ ---           │
        │ array[i64, 3] ┆ array[i64, 3] │
        ╞═══════════════╪═══════════════╡
        │ [3, 2, 1]     ┆ [3, 2, 1]     │
        │ [9, 1, 2]     ┆ [9, 2, 1]     │
        └───────────────┴───────────────┘
        )r   r   Úarr_sort)r   r[   r\   s      r   ÚsortzExprArrayNameSpace.sort  s!   € ôP ˜Ÿ™×.Ñ.¨z¸:ÓFÓGÐGr   c                óH   — t        | j                  j                  «       «      S )u˜  
        Reverse the arrays in this column.

        Examples
        --------
        >>> df = pl.DataFrame(
        ...     {
        ...         "a": [[3, 2, 1], [9, 1, 2]],
        ...     },
        ...     schema={"a": pl.Array(pl.Int64, 3)},
        ... )
        >>> df.with_columns(reverse=pl.col("a").arr.reverse())
        shape: (2, 2)
        ┌───────────────┬───────────────┐
        │ a             ┆ reverse       │
        │ ---           ┆ ---           │
        │ array[i64, 3] ┆ array[i64, 3] │
        ╞═══════════════╪═══════════════╡
        │ [3, 2, 1]     ┆ [1, 2, 3]     │
        │ [9, 1, 2]     ┆ [2, 1, 9]     │
        └───────────────┴───────────────┘
        )r   r   Úarr_reverser   s    r   ÚreversezExprArrayNameSpace.reverse:  s   € ô. ˜Ÿ™×1Ñ1Ó3Ó4Ð4r   c                óH   — t        | j                  j                  «       «      S )uô  
        Retrieve the index of the minimal value in every sub-array.

        Returns
        -------
        Expr
            Expression of data type :class:`UInt32` or :class:`UInt64`
            (depending on compilation).

        Examples
        --------
        >>> df = pl.DataFrame(
        ...     {
        ...         "a": [[1, 2], [2, 1]],
        ...     },
        ...     schema={"a": pl.Array(pl.Int64, 2)},
        ... )
        >>> df.with_columns(arg_min=pl.col("a").arr.arg_min())
        shape: (2, 2)
        ┌───────────────┬─────────┐
        │ a             ┆ arg_min │
        │ ---           ┆ ---     │
        │ array[i64, 2] ┆ u32     │
        ╞═══════════════╪═════════╡
        │ [1, 2]        ┆ 0       │
        │ [2, 1]        ┆ 1       │
        └───────────────┴─────────┘
        )r   r   Úarr_arg_minr   s    r   Úarg_minzExprArrayNameSpace.arg_minS  ó   € ô: ˜Ÿ™×1Ñ1Ó3Ó4Ð4r   c                óH   — t        | j                  j                  «       «      S )uô  
        Retrieve the index of the maximum value in every sub-array.

        Returns
        -------
        Expr
            Expression of data type :class:`UInt32` or :class:`UInt64`
            (depending on compilation).

        Examples
        --------
        >>> df = pl.DataFrame(
        ...     {
        ...         "a": [[1, 2], [2, 1]],
        ...     },
        ...     schema={"a": pl.Array(pl.Int64, 2)},
        ... )
        >>> df.with_columns(arg_max=pl.col("a").arr.arg_max())
        shape: (2, 2)
        ┌───────────────┬─────────┐
        │ a             ┆ arg_max │
        │ ---           ┆ ---     │
        │ array[i64, 2] ┆ u32     │
        ╞═══════════════╪═════════╡
        │ [1, 2]        ┆ 1       │
        │ [2, 1]        ┆ 0       │
        └───────────────┴─────────┘
        )r   r   Úarr_arg_maxr   s    r   Úarg_maxzExprArrayNameSpace.arg_maxr  rf   r   ©Únull_on_oobc               ób   — t        |«      }t        | j                  j                  ||«      «      S )uk  
        Get the value by index in the sub-arrays.

        So index `0` would return the first item of every sublist
        and index `-1` would return the last item of every sublist
        if an index is out of bounds, it will return a `None`.

        Parameters
        ----------
        index
            Index to return per sub-array
        null_on_oob
            Behavior if an index is out of bounds:
            True -> set as null
            False -> raise an error

        Examples
        --------
        >>> df = pl.DataFrame(
        ...     {"arr": [[1, 2, 3], [4, 5, 6], [7, 8, 9]], "idx": [1, -2, 0]},
        ...     schema={"arr": pl.Array(pl.Int32, 3), "idx": pl.Int32},
        ... )
        >>> df.with_columns(get=pl.col("arr").arr.get("idx", null_on_oob=True))
        shape: (3, 3)
        ┌───────────────┬─────┬─────┐
        │ arr           ┆ idx ┆ get │
        │ ---           ┆ --- ┆ --- │
        │ array[i32, 3] ┆ i32 ┆ i32 │
        ╞═══════════════╪═════╪═════╡
        │ [1, 2, 3]     ┆ 1   ┆ 2   │
        │ [4, 5, 6]     ┆ -2  ┆ 5   │
        │ [7, 8, 9]     ┆ 0   ┆ 7   │
        └───────────────┴─────┴─────┘
        )r   r   r   Úarr_get)r   Úindexrk   Úindex_pyexprs       r   ÚgetzExprArrayNameSpace.get‘  s+   € ôF -¨UÓ3ˆÜ˜Ÿ™×-Ñ-¨l¸KÓHÓIÐIr   c                ó(   — | j                  dd¬«      S )u4  
        Get the first value of the sub-arrays.

        Examples
        --------
        >>> df = pl.DataFrame(
        ...     {"a": [[1, 2, 3], [4, 5, 6], [7, 8, 9]]},
        ...     schema={"a": pl.Array(pl.Int32, 3)},
        ... )
        >>> df.with_columns(first=pl.col("a").arr.first())
        shape: (3, 2)
        ┌───────────────┬───────┐
        │ a             ┆ first │
        │ ---           ┆ ---   │
        │ array[i32, 3] ┆ i32   │
        ╞═══════════════╪═══════╡
        │ [1, 2, 3]     ┆ 1     │
        │ [4, 5, 6]     ┆ 4     │
        │ [7, 8, 9]     ┆ 7     │
        └───────────────┴───────┘
        r   Trj   ©rp   r   s    r   ÚfirstzExprArrayNameSpace.first·  s   € ð, �x‰x˜ tˆxÓ,Ð,r   c                ó(   — | j                  dd¬«      S )u"  
        Get the last value of the sub-arrays.

        Examples
        --------
        >>> df = pl.DataFrame(
        ...     {"a": [[1, 2, 3], [4, 5, 6], [7, 9, 8]]},
        ...     schema={"a": pl.Array(pl.Int32, 3)},
        ... )
        >>> df.with_columns(last=pl.col("a").arr.last())
        shape: (3, 2)
        ┌───────────────┬──────┐
        │ a             ┆ last │
        │ ---           ┆ ---  │
        │ array[i32, 3] ┆ i32  │
        ╞═══════════════╪══════╡
        │ [1, 2, 3]     ┆ 3    │
        │ [4, 5, 6]     ┆ 6    │
        │ [7, 9, 8]     ┆ 8    │
        └───────────────┴──────┘
        éÿÿÿÿTrj   rr   r   s    r   ÚlastzExprArrayNameSpace.lastÏ  s   € ð, �x‰x˜¨ˆxÓ-Ð-r   c               óf   — t        |d¬«      }t        | j                  j                  ||«      «      S )u  
        Join all string items in a sub-array and place a separator between them.

        This errors if inner type of array `!= String`.

        Parameters
        ----------
        separator
            string to separate the items with
        ignore_nulls
            Ignore null values (default).

            If set to ``False``, null values will be propagated.
            If the sub-list contains any null values, the output is ``None``.

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

        Examples
        --------
        >>> df = pl.DataFrame(
        ...     {"s": [["a", "b"], ["x", "y"]], "separator": ["*", "_"]},
        ...     schema={
        ...         "s": pl.Array(pl.String, 2),
        ...         "separator": pl.String,
        ...     },
        ... )
        >>> df.with_columns(join=pl.col("s").arr.join(pl.col("separator")))
        shape: (2, 3)
        ┌───────────────┬───────────┬──────┐
        │ s             ┆ separator ┆ join │
        │ ---           ┆ ---       ┆ ---  │
        │ array[str, 2] ┆ str       ┆ str  │
        ╞═══════════════╪═══════════╪══════╡
        │ ["a", "b"]    ┆ *         ┆ a*b  │
        │ ["x", "y"]    ┆ _         ┆ x_y  │
        └───────────────┴───────────┴──────┘
        T©Ú
str_as_lit)r   r   r   Úarr_join)r   Ú	separatorrQ   Úseparator_pyexprs       r   ÚjoinzExprArrayNameSpace.joinç  s/   € ôR 1°ÀtÔLÐÜ˜Ÿ™×.Ñ.Ð/?ÀÓNÓOÐOr   ©Úempty_as_nullÚ
keep_nullsc               óN   — t        | j                  j                  ||¬«      «      S )uj  
        Returns a column with a separate row for every array element.

        Parameters
        ----------
        empty_as_null
            Explode an empty array into a `null`.
        keep_nulls
            Explode a `null` array into a `null`.

        Returns
        -------
        Expr
            Expression with the data type of the array elements.

        Examples
        --------
        >>> df = pl.DataFrame(
        ...     {"a": [[1, 2, 3], [4, 5, 6]]}, schema={"a": pl.Array(pl.Int64, 3)}
        ... )
        >>> df.select(pl.col("a").arr.explode())
        shape: (6, 1)
        ┌─────┐
        │ a   │
        │ --- │
        │ i64 │
        ╞═════╡
        │ 1   │
        │ 2   │
        │ 3   │
        │ 4   │
        │ 5   │
        │ 6   │
        └─────┘
        r~   )r   r   Úarr_explode)r   r   r€   s      r   ÚexplodezExprArrayNameSpace.explode  s)   € ôH Ø�L‰L×$Ñ$°=ÈZÐ$ÓXó
ð 	
r   )Únulls_equalc               óf   — t        |d¬«      }t        | j                  j                  ||«      «      S )u¾  
        Check if sub-arrays contain the given item.

        Parameters
        ----------
        item
            Item that will be checked for membership
        nulls_equal : bool, default True
            If True, treat null as a distinct value. Null values will not propagate.

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

        Examples
        --------
        >>> df = pl.DataFrame(
        ...     {"a": [["a", "b"], ["x", "y"], ["a", "c"]]},
        ...     schema={"a": pl.Array(pl.String, 2)},
        ... )
        >>> df.with_columns(contains=pl.col("a").arr.contains("a"))
        shape: (3, 2)
        ┌───────────────┬──────────┐
        │ a             ┆ contains │
        │ ---           ┆ ---      │
        │ array[str, 2] ┆ bool     │
        ╞═══════════════╪══════════╡
        │ ["a", "b"]    ┆ true     │
        │ ["x", "y"]    ┆ false    │
        │ ["a", "c"]    ┆ true     │
        └───────────────┴──────────┘
        Trx   )r   r   r   Úarr_contains)r   Úitemr„   Úitem_pyexprs       r   ÚcontainszExprArrayNameSpace.contains;  s-   € ôD ,¨D¸TÔBˆÜ˜Ÿ™×2Ñ2°;ÀÓLÓMÐMr   c                ód   — t        |d¬«      }t        | j                  j                  |«      «      S )u2  
        Count how often the value produced by `element` occurs.

        Parameters
        ----------
        element
            An expression that produces a single value

        Examples
        --------
        >>> df = pl.DataFrame(
        ...     {"a": [[1, 2], [1, 1], [2, 2]]}, schema={"a": pl.Array(pl.Int64, 2)}
        ... )
        >>> df.with_columns(number_of_twos=pl.col("a").arr.count_matches(2))
        shape: (3, 2)
        ┌───────────────┬────────────────┐
        │ a             ┆ number_of_twos │
        │ ---           ┆ ---            │
        │ array[i64, 2] ┆ u32            │
        ╞═══════════════╪════════════════╡
        │ [1, 2]        ┆ 1              │
        │ [1, 1]        ┆ 0              │
        │ [2, 2]        ┆ 2              │
        └───────────────┴────────────────┘
        Trx   )r   r   r   Úarr_count_matches)r   rU   Úelement_pyexprs      r   Úcount_matchesz ExprArrayNameSpace.count_matches`  s*   € ô4 /¨wÀ4ÔHˆÜ˜Ÿ™×7Ñ7¸ÓGÓHÐHr   c                ó  — t        |t        «      rJt        |«      }| j                  j	                  d«      }t        |«      j                  j                  |«      S | j                  j	                  |«      }t        |«      S )uÆ  
        Convert the Series of type `Array` to a Series of type `Struct`.

        Parameters
        ----------
        fields
            If the name and number of the desired fields is known in advance
            a list of field names can be given, which will be assigned by index.
            Otherwise, to dynamically assign field names, a custom function can be
            used; if neither are set, fields will be `field_0, field_1 .. field_n`.

        Examples
        --------
        Convert array to struct with default field name assignment:

        >>> df = pl.DataFrame(
        ...     {"n": [[0, 1, 2], [3, 4, 5]]}, schema={"n": pl.Array(pl.Int8, 3)}
        ... )
        >>> df.with_columns(struct=pl.col("n").arr.to_struct())
        shape: (2, 2)
        ┌──────────────┬───────────┐
        │ n            ┆ struct    │
        │ ---          ┆ ---       │
        │ array[i8, 3] ┆ struct[3] │
        ╞══════════════╪═══════════╡
        │ [0, 1, 2]    ┆ {0,1,2}   │
        │ [3, 4, 5]    ┆ {3,4,5}   │
        └──────────────┴───────────┘

        Convert array to struct with field name assignment by function/index:

        >>> df = pl.DataFrame(
        ...     {"n": [[0, 1, 2], [3, 4, 5]]}, schema={"n": pl.Array(pl.Int8, 3)}
        ... )
        >>> df.select(pl.col("n").arr.to_struct(fields=lambda idx: f"n{idx}")).rows(
        ...     named=True
        ... )
        [{'n': {'n0': 0, 'n1': 1, 'n2': 2}}, {'n': {'n0': 3, 'n1': 4, 'n2': 5}}]

        Convert array to struct with field name assignment by
        index from a list of names:

        >>> df.select(pl.col("n").arr.to_struct(fields=["c1", "c2", "c3"])).rows(
        ...     named=True
        ... )
        [{'n': {'c1': 0, 'c2': 1, 'c3': 2}}, {'n': {'c1': 3, 'c2': 4, 'c3': 5}}]
        N)Ú
isinstancer   Úlistr   Úarr_to_structr   ÚstructÚrename_fields)r   ÚfieldsÚfield_namesÚpyexprs       r   Ú	to_structzExprArrayNameSpace.to_struct}  sg   € ôd �fœhÔ'Ü˜v›,ˆKØ—\‘\×/Ñ/°Ó5ˆFÜ˜VÓ$×+Ñ+×9Ñ9¸+ÓFÐFà—\‘\×/Ñ/°Ó7ˆFÜ˜VÓ$Ð$r   c                ó`   — t        |«      }t        | j                  j                  |«      «      S )u  
        Shift array values by the given number of indices.

        Parameters
        ----------
        n
            Number of indices to shift forward. If a negative value is passed, values
            are shifted in the opposite direction instead.

        Notes
        -----
        This method is similar to the `LAG` operation in SQL when the value for `n`
        is positive. With a negative value for `n`, it is similar to `LEAD`.

        Examples
        --------
        By default, array values are shifted forward by one index.

        >>> df = pl.DataFrame(
        ...     {"a": [[1, 2, 3], [4, 5, 6]]}, schema={"a": pl.Array(pl.Int64, 3)}
        ... )
        >>> df.with_columns(shift=pl.col("a").arr.shift())
        shape: (2, 2)
        ┌───────────────┬───────────────┐
        │ a             ┆ shift         │
        │ ---           ┆ ---           │
        │ array[i64, 3] ┆ array[i64, 3] │
        ╞═══════════════╪═══════════════╡
        │ [1, 2, 3]     ┆ [null, 1, 2]  │
        │ [4, 5, 6]     ┆ [null, 4, 5]  │
        └───────────────┴───────────────┘

        Pass a negative value to shift in the opposite direction instead.

        >>> df.with_columns(shift=pl.col("a").arr.shift(-2))
        shape: (2, 2)
        ┌───────────────┬─────────────────┐
        │ a             ┆ shift           │
        │ ---           ┆ ---             │
        │ array[i64, 3] ┆ array[i64, 3]   │
        ╞═══════════════╪═════════════════╡
        │ [1, 2, 3]     ┆ [3, null, null] │
        │ [4, 5, 6]     ┆ [6, null, null] │
        └───────────────┴─────────────────┘
        )r   r   r   Ú	arr_shift)r   r(   r,   s      r   ÚshiftzExprArrayNameSpace.shift·  s)   € ô\ )¨Ó+ˆÜ˜Ÿ™×/Ñ/°Ó9Ó:Ð:r   ©Úas_listc               ób   — t        | j                  j                  |j                  |¬«      «      S )u  
        Run any polars expression against the arrays' elements.

        Parameters
        ----------
        expr
            Expression to run. Note that you can select an element with `pl.element()`
        as_list
            Collect the resulting data as a list. This allows for expressions which
            output a variable amount of data.

        Examples
        --------
        >>> df = pl.DataFrame({"a": [1, 8, 3], "b": [4, 5, 2]})
        >>> df.with_columns(rank=pl.concat_arr("a", "b").arr.eval(pl.element().rank()))
        shape: (3, 3)
        ┌─────┬─────┬───────────────┐
        │ a   ┆ b   ┆ rank          │
        │ --- ┆ --- ┆ ---           │
        │ i64 ┆ i64 ┆ array[f64, 2] │
        ╞═════╪═════╪═══════════════╡
        │ 1   ┆ 4   ┆ [1.0, 2.0]    │
        │ 8   ┆ 5   ┆ [2.0, 1.0]    │
        │ 3   ┆ 2   ┆ [2.0, 1.0]    │
        └─────┴─────┴───────────────┘

        See Also
        --------
        polars.Expr.arr.agg: Evaluate any expression and automatically explode.
        polars.Expr.list.eval: Same for the List datatype.
        r›   )r   r   Úarr_eval)r   r   rœ   s      r   ÚevalzExprArrayNameSpace.evalè  s(   € ô@ ˜Ÿ™×.Ñ.¨t¯|©|ÀWÐ.ÓMÓNÐNr   c                ó^   — t        | j                  j                  |j                  «      «      S )uh  
        Run any polars aggregation expression against the arrays' elements.

        Parameters
        ----------
        expr
            Expression to run. Note that you can select an element with `pl.element()`.

        Examples
        --------
        >>> df = pl.Series(
        ...     "a", [[1, None], [42, 13], [None, None]], pl.Array(pl.Int64, 2)
        ... ).to_frame()
        >>> df.with_columns(null_count=pl.col.a.arr.agg(pl.element().null_count()))
        shape: (3, 2)
        ┌───────────────┬────────────┐
        │ a             ┆ null_count │
        │ ---           ┆ ---        │
        │ array[i64, 2] ┆ u32        │
        ╞═══════════════╪════════════╡
        │ [1, null]     ┆ 1          │
        │ [42, 13]      ┆ 0          │
        │ [null, null]  ┆ 2          │
        └───────────────┴────────────┘
        >>> df.with_columns(no_nulls=pl.col.a.arr.agg(pl.element().drop_nulls()))
        shape: (3, 2)
        ┌───────────────┬───────────┐
        │ a             ┆ no_nulls  │
        │ ---           ┆ ---       │
        │ array[i64, 2] ┆ list[i64] │
        ╞═══════════════╪═══════════╡
        │ [1, null]     ┆ [1]       │
        │ [42, 13]      ┆ [42, 13]  │
        │ [null, null]  ┆ []        │
        └───────────────┴───────────┘

        See Also
        --------
        polars.Expr.arr.eval: Evaluate any expression without automatic explode.
        polars.Expr.list.agg: Same for the List datatype.
        )r   r   Úarr_aggr   s     r   rS   zExprArrayNameSpace.agg
  s#   € ôT ˜Ÿ™×-Ñ-¨d¯l©lÓ;Ó<Ð<r   )r   r
   ÚreturnÚNone)r¢   r
   r   )r"   úint | str | Exprr#   zint | str | Expr | Noner   Úboolr¢   r
   )é   )r(   r¤   r   r¥   r¢   r
   )é   )r:   Úintr¢   r
   )rF   r¥   r¢   r
   )rQ   r¥   r¢   r
   )r[   r¥   r\   r¥   r¢   r
   )rn   úint | IntoExprColumnrk   r¥   r¢   r
   )r{   r   rQ   r¥   r¢   r
   )r   r¥   r€   r¥   r¢   r
   )r‡   r   r„   r¥   r¢   r
   )rU   r   r¢   r
   )r”   z+Sequence[str] | Callable[[int], str] | Noner¢   r
   )r(   r©   r¢   r
   )r   r
   rœ   r¥   r¢   r
   )r   r
   r¢   r
   )%Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	_accessorr   r   r&   r)   r-   r0   r3   r6   r;   r?   rB   rE   rI   rL   rO   rV   rZ   r_   rb   re   ri   rp   rs   rv   r}   rƒ   r‰   r�   r—   rš   rŸ   rS   © r   r   r   r      sX  „ Ù2à€Ió$ó1ð4 +/ð6Yð
 ñ6Yà ð6Yð (ð6Yð
 ð6Yð 
ó6Yðp+3Àõ +3ðZ,DÀõ ,Dó\1ó.1ó.1ô.5ô.5ó.2ó.4ð. 05õ Bó:6ó25ð8 +/õ +DðZ +/õ +DðZ */À5õ (HóT5ó25ó>5ð> GLõ $JóL-ó0.ð0 GKõ *PðX 04Èõ &
ðP ?Cõ #NóJIð< EIð8%ØAð8%à	ó8%ôt/;ðb 38õ  OôD*=r   r   N)Ú
__future__r   Úcollections.abcr   Útypingr   Úpolarsr   rT   Úpolars._utils.parser   Úpolars._utils.wrapr   r	   r
   Úpolars._typingr   r   r   r¯   r   r   ú<module>r·      s/   ðÝ "å $Ý  å !Ý 5Ý (áÝ(åß7÷c=ò c=r   