ó
    à'·h-‰  ã                  ó‚   • S SK Jr  S SKJr  S SKJrJr  S SKJr  S SK	J
r
  \(       a  S SKJr  S SKJrJr   " S S	5      rg
)é    )Úannotations)ÚSequence)ÚTYPE_CHECKINGÚCallable)Úparse_into_expression)Ú	wrap_expr)ÚExpr)ÚIntoExprÚIntoExprColumnc                  ó¾  • \ rS rSrSrSrS,S jrS-S jr S.SS.       S/S	 jjjrS0SS.S1S
 jjjr	S0SS.S1S jjjr
S-S jrS-S jrS-S jrS2S3S jjrS2S3S jjrS-S jrS-S jrSS.S4S jjrS-S jrS-S jrS-S jrS-S jrSSS.S5S jjrS-S jrS-S jrS-S jrSS.S6S jjrS-S  jrS-S! jrS"S#.S7S$ jjrS-S% jrS"S&.S8S' jjr S9S( jr! S.   S:S) jjr"S2S;S* jjr#S+r$g)<ÚExprArrayNameSpaceé   z(Namespace for array related expressions.Úarrc                ó&   • UR                   U l         g ©N©Ú_pyexpr)ÚselfÚexprs     ÚdC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\polars/expr/array.pyÚ__init__ÚExprArrayNameSpace.__init__   s   € Ø—|‘|ˆó    c                óH   • [        U R                  R                  5       5      $ )ub  
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   ÚlenÚExprArrayNameSpace.len   ó   € ô* ˜Ÿ™×-Ñ-Ó/Ó0Ð0r   NF©Úas_arrayc               ó‚   • [        U5      nUb  [        U5      OSn[        U R                  R                  XEU5      5      $ )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   ÚsliceÚExprArrayNameSpace.slice-   s>   € ôh .¨fÓ5ˆØ9?Ñ9KÔ-¨fÔ5ÐQUˆÜ˜Ÿ™×/Ñ/°ÈhÓWÓXÐXr   c               ó"   • U R                  SXS9$ )u8  
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   ÚheadÚExprArrayNameSpace.heade   s   € ðV z‰z˜!˜QˆzÐ2Ð2r   c               ó`   • [        U5      n[        U R                  R                  X25      5      $ )u6  
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   ÚtailÚExprArrayNameSpace.tail’   s)   € ôV )¨Ó+ˆÜ˜Ÿ™×.Ñ.¨xÓBÓCÐCr   c                óH   • [        U R                  R                  5       5      $ )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   ÚminÚExprArrayNameSpace.minÀ   r   r   c                óH   • [        U R                  R                  5       5      $ )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   ÚmaxÚExprArrayNameSpace.max×   r   r   c                óH   • [        U R                  R                  5       5      $ )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   ÚsumÚExprArrayNameSpace.sumî   r   r   c                óJ   • [        U R                  R                  U5      5      $ )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   ÚstdÚExprArrayNameSpace.std  ó   € ô* ˜Ÿ™×-Ñ-¨dÓ3Ó4Ð4r   c                óJ   • [        U R                  R                  U5      5      $ )uf  
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_varrA   s     r   ÚvarÚExprArrayNameSpace.var  rE   r   c                óH   • [        U R                  R                  5       5      $ )uo  
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   ÚmeanÚExprArrayNameSpace.mean3  s   € ô* ˜Ÿ™×.Ñ.Ó0Ó1Ð1r   c                óH   • [        U R                  R                  5       5      $ )ul  
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   ÚmedianÚExprArrayNameSpace.medianJ  s   € ô* ˜Ÿ™×0Ñ0Ó2Ó3Ð3r   )Úmaintain_orderc               óJ   • [        U R                  R                  U5      5      $ )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   rR   s     r   ÚuniqueÚExprArrayNameSpace.uniquea  s   € ô6 ˜Ÿ™×0Ñ0°Ó@ÓAÐAr   c                óH   • [        U R                  R                  5       5      $ )uÈ  
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_uniqueÚExprArrayNameSpace.n_unique~  s   € ô. ˜Ÿ™×2Ñ2Ó4Ó5Ð5r   c                óH   • [        U R                  R                  5       5      $ )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_listÚExprArrayNameSpace.to_list—  s   € ô4 ˜Ÿ™×1Ñ1Ó3Ó4Ð4r   c                óH   • [        U R                  R                  5       5      $ )u  
Evaluate whether any boolean value is true for every subarray.

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  â”‚
â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”˜
)r   r   Úarr_anyr   s    r   ÚanyÚExprArrayNameSpace.any³  ó   € ô@ ˜Ÿ™×-Ñ-Ó/Ó0Ð0r   c                óH   • [        U R                  R                  5       5      $ )uŸ  
Evaluate whether all boolean values are true for every subarray.

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  â”‚
â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”˜
)r   r   Úarr_allr   s    r   ÚallÚExprArrayNameSpace.allÕ  rc   r   )Ú
descendingÚ
nulls_lastc               óJ   • [        U R                  R                  X5      5      $ )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   rh   ri   s      r   ÚsortÚExprArrayNameSpace.sort÷  s   € ôP ˜Ÿ™×.Ñ.¨zÓFÓGÐGr   c                óH   • [        U R                  R                  5       5      $ )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   ÚreverseÚExprArrayNameSpace.reverse!  s   € ô. ˜Ÿ™×1Ñ1Ó3Ó4Ð4r   c                óH   • [        U R                  R                  5       5      $ )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_minÚExprArrayNameSpace.arg_min:  ó   € ô: ˜Ÿ™×1Ñ1Ó3Ó4Ð4r   c                óH   • [        U R                  R                  5       5      $ )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_maxÚExprArrayNameSpace.arg_maxY  rv   r   ©Únull_on_oobc               ó`   • [        U5      n[        U R                  R                  X25      5      $ )u{  
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   Úindexr|   Úindex_pyexprs       r   ÚgetÚExprArrayNameSpace.getx  s)   € ôF -¨UÓ3ˆÜ˜Ÿ™×-Ñ-¨lÓHÓIÐIr   c                ó"   • U R                  SSS9$ )uœ  
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   Tr{   ©r   r   s    r   ÚfirstÚExprArrayNameSpace.firstž  s   € ð, x‰x˜ tˆxÐ,Ð,r   c                ó"   • U R                  SSS9$ )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    â”‚
â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”˜
éÿÿÿÿTr{   r„   r   s    r   ÚlastÚExprArrayNameSpace.last¶  s   € ð, x‰x˜¨ˆxÐ-Ð-r   T)Úignore_nullsc               ó^   • [        USS9n[        U R                  R                  X25      5      $ )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   Ú	separatorr‹   Úseparator_pyexprs       r   ÚjoinÚExprArrayNameSpace.joinÎ  s-   € ôR 1°ÀtÑLÐÜ˜Ÿ™×.Ñ.Ð/?ÓNÓOÐOr   c                óH   • [        U R                  R                  5       5      $ )uî  
Returns a column with a separate row for every array element.

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   Úarr_exploder   s    r   ÚexplodeÚExprArrayNameSpace.explodeú  rv   r   )Únulls_equalc               ó^   • [        USS9n[        U R                  R                  X25      5      $ )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     â”‚
â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”˜
Tr   )r   r   r   Úarr_contains)r   Úitemr˜   Úitem_pyexprs       r   ÚcontainsÚExprArrayNameSpace.contains  s+   € ôD ,¨D¸TÑBˆÜ˜Ÿ™×2Ñ2°;ÓLÓMÐMr   c                ó^   • [        USS9n[        U R                  R                  U5      5      $ )u‚  
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              â”‚
â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”˜
Tr   )r   r   r   Úarr_count_matches)r   ÚelementÚelement_pyexprs      r   Úcount_matchesÚ ExprArrayNameSpace.count_matches>  s*   € ô4 /¨wÀ4ÑHˆÜ˜Ÿ™×7Ñ7¸ÓGÓHÐHr   c                ó  • [        U[        5      (       aJ  [        U5      nU R                  R	                  S5      n[        U5      R                  R                  U5      $ U R                  R	                  U5      n[        U5      $ )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_structÚExprArrayNameSpace.to_struct[  sj   € ôd fœh×'Ñ'Ü˜v›,ˆKØ—\‘\×/Ñ/°Ó5ˆFÜ˜VÓ$×+Ñ+×9Ñ9¸+ÓFÐFà—\‘\×/Ñ/°Ó7ˆFÜ˜VÓ$Ð$r   c                ó`   • [        U5      n[        U R                  R                  U5      5      $ )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+   r0   s      r   ÚshiftÚExprArrayNameSpace.shift•  s)   € ô\ )¨Ó+ˆÜ˜Ÿ™×/Ñ/°Ó9Ó:Ð:r   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	   )é   )rB   Úintr´   r	   )rR   r·   r´   r	   )rh   r·   ri   r·   r´   r	   )r   úint | IntoExprColumnr|   r·   r´   r	   )r   r   r‹   r·   r´   r	   )r›   r
   r˜   r·   r´   r	   )r¡   r
   r´   r	   )r«   z+Sequence[str] | Callable[[int], str] | Noner´   r	   )r+   r»   r´   r	   )%Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú	_accessorr   r   r(   r,   r1   r5   r9   r=   rC   rH   rL   rP   rU   rY   r]   ra   rf   rl   rp   rt   ry   r   r…   r‰   r’   r–   r   r£   r®   r²   Ú__static_attributes__© r   r   r   r      sB  † Ù2à€Iô$ô1ð4 +/ð6Yð
 ñ6Yà ð6Yð (ð6Yð
 ð6Yð 
ö6Yðp+3À÷ +3ð +3ðZ,DÀ÷ ,Dð ,Dô\1ô.1ô.1ö.5ö.5ô.2ô.4ð. 05÷ Bô:6ô25ô8 1ôD 1ðD */À5÷ (HôT5ô25ô>5ð> GL÷ $JôL-ô0.ð0 GK÷ *PôX5ð> ?C÷ #NôJIð< EIð8%ØAð8%à	õ8%÷t/;ñ /;r   r   N)Ú
__future__r   Úcollections.abcr   Útypingr   r   Úpolars._utils.parser   Úpolars._utils.wrapr   Úpolarsr	   Úpolars._typingr
   r   r   rÃ   r   r   Ú<module>rË      s)   ðÝ "å $ß *å 5Ý (æÝß7÷v;ò v;r   