Ë
    7Ò^j¦7  ã                  ó€   — d dl mZ d dlmZmZmZ d dlmZmZ erd dl	m
Z
 d dlmZ  edd¬«      Z G d	„ d
ee   «      Zy)é    )Úannotations)ÚTYPE_CHECKINGÚGenericÚTypeVar)ÚExprKindÚExprNode)ÚExpr)ÚNonNestedLiteralÚExprTr	   )Úboundc                  ól   — e Zd Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Z	dd„Z
dd	„Zdd
„Zdddœdd„Zy)ÚExprListNamespacec                ó   — || _         y )N)Ú_expr)ÚselfÚexprs     ú]/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/narwhals/expr_list.pyÚ__init__zExprListNamespace.__init__   s	   € Øˆ�
ó    c                óh   — | j                   j                  t        t        j                  d«      «      S )ué  Return the number of elements in each list.

        Null values count towards the total.

        Examples:
            >>> import polars as pl
            >>> import narwhals as nw
            >>> df_native = pl.DataFrame({"a": [[1, 2], [3, 4, None], None, []]})
            >>> df = nw.from_native(df_native)
            >>> df.with_columns(a_len=nw.col("a").list.len())
            ┌────────────────────────┐
            |   Narwhals DataFrame   |
            |------------------------|
            |shape: (4, 2)           |
            |┌──────────────┬───────┐|
            |│ a            ┆ a_len │|
            |│ ---          ┆ ---   │|
            |│ list[i64]    ┆ u32   │|
            |╞══════════════╪═══════╡|
            |│ [1, 2]       ┆ 2     │|
            |│ [3, 4, null] ┆ 3     │|
            |│ null         ┆ null  │|
            |│ []           ┆ 0     │|
            |└──────────────┴───────┘|
            └────────────────────────┘
        zlist.len©r   Ú_append_noder   r   ÚELEMENTWISE©r   s    r   ÚlenzExprListNamespace.len   s&   € ð6 �z‰z×&Ñ&¤x´×0DÑ0DÀjÓ'QÓRÐRr   c                óh   — | j                   j                  t        t        j                  d«      «      S )u™  Get the unique/distinct values in the list.

        Null values are included in the result. The order of unique values is not guaranteed.

        Examples:
            >>> import polars as pl
            >>> import narwhals as nw
            >>> df_native = pl.DataFrame({"a": [[1, 1, 2], [3, 3, None], None, []]})
            >>> df = nw.from_native(df_native)
            >>> df.with_columns(a_unique=nw.col("a").list.unique())  # doctest: +SKIP
            ┌────────────────────────────┐
            |     Narwhals DataFrame     |
            |----------------------------|
            |shape: (4, 2)               |
            |┌──────────────┬───────────┐|
            |│ a            ┆ a_unique  │|
            |│ ---          ┆ ---       │|
            |│ list[i64]    ┆ list[i64] │|
            |╞══════════════╪═══════════╡|
            |│ [1, 1, 2]    ┆ [1, 2]    │|
            |│ [3, 3, null] ┆ [null, 3] │|
            |│ null         ┆ null      │|
            |│ []           ┆ []        │|
            |└──────────────┴───────────┘|
            └────────────────────────────┘
        zlist.uniquer   r   s    r   ÚuniquezExprListNamespace.unique/   s&   € ð6 �z‰z×&Ñ&¤x´×0DÑ0DÀmÓ'TÓUÐUr   c                ól   — | j                   j                  t        t        j                  d|¬«      «      S )u;  Check if sublists contain the given item.

        Arguments:
            item: Item that will be checked for membership.

        Examples:
            >>> import polars as pl
            >>> import narwhals as nw
            >>> df_native = pl.DataFrame({"a": [[1, 2], None, []]})
            >>> df = nw.from_native(df_native)
            >>> df.with_columns(a_contains_1=nw.col("a").list.contains(1))
            ┌────────────────────────────┐
            |     Narwhals DataFrame     |
            |----------------------------|
            |shape: (3, 2)               |
            |┌───────────┬──────────────┐|
            |│ a         ┆ a_contains_1 │|
            |│ ---       ┆ ---          │|
            |│ list[i64] ┆ bool         │|
            |╞═══════════╪══════════════╡|
            |│ [1, 2]    ┆ true         │|
            |│ null      ┆ null         │|
            |│ []        ┆ false        │|
            |└───────────┴──────────────┘|
            └────────────────────────────┘
        zlist.contains)Úitemr   )r   r   s     r   ÚcontainszExprListNamespace.containsL   s-   € ð6 �z‰z×&Ñ&Ü”X×)Ñ)¨?ÀÔFó
ð 	
r   c                ó   — t        |t        «      s$dt        |«      j                  › d�}t	        |«      ‚|dk  rd|› d�}t        |«      ‚| j                  j                  t        t        j                  d|¬«      «      S )uê  Return the value by index in each list.

        Negative indices are not accepted.

        Examples:
            >>> import polars as pl
            >>> import narwhals as nw
            >>> df_native = pl.DataFrame({"a": [[1, 2], [3, 4, None], [None, 5]]})
            >>> df = nw.from_native(df_native)
            >>> df.with_columns(a_first=nw.col("a").list.get(0))
            ┌──────────────────────────┐
            |    Narwhals DataFrame    |
            |--------------------------|
            |shape: (3, 2)             |
            |┌──────────────┬─────────┐|
            |│ a            ┆ a_first │|
            |│ ---          ┆ ---     │|
            |│ list[i64]    ┆ i64     │|
            |╞══════════════╪═════════╡|
            |│ [1, 2]       ┆ 1       │|
            |│ [3, 4, null] ┆ 3       │|
            |│ [null, 5]    ┆ null    │|
            |└──────────────┴─────────┘|
            └──────────────────────────┘
        z'Index must be of type 'int'. Got type 'z
' instead.r   zIndex z8 is out of bounds: should be greater than or equal to 0.zlist.get)Úindex)Ú
isinstanceÚintÚtypeÚ__name__Ú	TypeErrorÚ
ValueErrorr   r   r   r   r   )r   r"   Úmsgs      r   ÚgetzExprListNamespace.getk   s   € ô4 ˜%¤Ô%à9¼$¸u»+×:NÑ:NÐ9OÈzÐZð ô ˜C“.Ð à�1Š9Ø˜5˜'Ð!YÐZˆCÜ˜S“/Ð!à�z‰z×&Ñ&Ü”X×)Ñ)¨:¸UÔCó
ð 	
r   c                óh   — | j                   j                  t        t        j                  d«      «      S )u  Compute the min value of the lists in the array.

        Examples:
            >>> import duckdb
            >>> import narwhals as nw
            >>> df_native = duckdb.sql("SELECT * FROM VALUES ([1]), ([3, 4, NULL]) df(a)")
            >>> df = nw.from_native(df_native)
            >>> df.with_columns(a_min=nw.col("a").list.min())
            ┌────────────────────────┐
            |   Narwhals LazyFrame   |
            |------------------------|
            |┌──────────────┬───────┐|
            |│      a       │ a_min │|
            |│   int32[]    │ int32 │|
            |├──────────────┼───────┤|
            |│ [1]          │     1 │|
            |│ [3, 4, NULL] │     3 │|
            |└──────────────┴───────┘|
            └────────────────────────┘
        zlist.minr   r   s    r   ÚminzExprListNamespace.min“   s&   € ð* �z‰z×&Ñ&¤x´×0DÑ0DÀjÓ'QÓRÐRr   c                óh   — | j                   j                  t        t        j                  d«      «      S )uY  Compute the max value of the lists in the array.

        Examples:
            >>> import polars as pl
            >>> import narwhals as nw
            >>> df_native = pl.DataFrame({"a": [[1], [3, 4, None]]})
            >>> df = nw.from_native(df_native)
            >>> df.with_columns(a_max=nw.col("a").list.max())
            ┌────────────────────────┐
            |   Narwhals DataFrame   |
            |------------------------|
            |shape: (2, 2)           |
            |┌──────────────┬───────┐|
            |│ a            ┆ a_max │|
            |│ ---          ┆ ---   │|
            |│ list[i64]    ┆ i64   │|
            |╞══════════════╪═══════╡|
            |│ [1]          ┆ 1     │|
            |│ [3, 4, null] ┆ 4     │|
            |└──────────────┴───────┘|
            └────────────────────────┘
        zlist.maxr   r   s    r   ÚmaxzExprListNamespace.maxª   ó&   € ð. �z‰z×&Ñ&¤x´×0DÑ0DÀjÓ'QÓRÐRr   c                óh   — | j                   j                  t        t        j                  d«      «      S )u?  Compute the mean value of the lists in the array.

        Examples:
            >>> import pyarrow as pa
            >>> import narwhals as nw
            >>> df_native = pa.table({"a": [[1], [3, 4, None]]})
            >>> df = nw.from_native(df_native)
            >>> df.with_columns(a_mean=nw.col("a").list.mean())
            ┌──────────────────────┐
            |  Narwhals DataFrame  |
            |----------------------|
            |pyarrow.Table         |
            |a: list<item: int64>  |
            |  child 0, item: int64|
            |a_mean: double        |
            |----                  |
            |a: [[[1],[3,4,null]]] |
            |a_mean: [[1,3.5]]     |
            └──────────────────────┘
        z	list.meanr   r   s    r   ÚmeanzExprListNamespace.meanÃ   s&   € ð* �z‰z×&Ñ&¤x´×0DÑ0DÀkÓ'RÓSÐSr   c                óh   — | j                   j                  t        t        j                  d«      «      S )u]  Compute the median value of the lists in the array.

        Examples:
            >>> import duckdb
            >>> import narwhals as nw
            >>> df_native = duckdb.sql("SELECT * FROM VALUES ([1]), ([3, 4, NULL]) df(a)")
            >>> df = nw.from_native(df_native)
            >>> df.with_columns(a_median=nw.col("a").list.median())
            ┌───────────────────────────┐
            |    Narwhals LazyFrame     |
            |---------------------------|
            |┌──────────────┬──────────┐|
            |│      a       │ a_median │|
            |│   int32[]    │  double  │|
            |├──────────────┼──────────┤|
            |│ [1]          │      1.0 │|
            |│ [3, 4, NULL] │      3.5 │|
            |└──────────────┴──────────┘|
            └───────────────────────────┘
        zlist.medianr   r   s    r   ÚmedianzExprListNamespace.medianÚ   s&   € ð* �z‰z×&Ñ&¤x´×0DÑ0DÀmÓ'TÓUÐUr   c                óh   — | j                   j                  t        t        j                  d«      «      S )uY  Compute the sum value of the lists in the array.

        Examples:
            >>> import polars as pl
            >>> import narwhals as nw
            >>> df_native = pl.DataFrame({"a": [[1], [3, 4, None]]})
            >>> df = nw.from_native(df_native)
            >>> df.with_columns(a_sum=nw.col("a").list.sum())
            ┌────────────────────────┐
            |   Narwhals DataFrame   |
            |------------------------|
            |shape: (2, 2)           |
            |┌──────────────┬───────┐|
            |│ a            ┆ a_sum │|
            |│ ---          ┆ ---   │|
            |│ list[i64]    ┆ i64   │|
            |╞══════════════╪═══════╡|
            |│ [1]          ┆ 1     │|
            |│ [3, 4, null] ┆ 7     │|
            |└──────────────┴───────┘|
            └────────────────────────┘
        zlist.sumr   r   s    r   ÚsumzExprListNamespace.sumñ   r/   r   F©Ú
descendingÚ
nulls_lastc               ón   — | j                   j                  t        t        j                  d||¬«      «      S )uk  Sort the lists of the expression.

        Arguments:
            descending: Sort in descending order.
            nulls_last: Place null values last.

        Examples:
            >>> import duckdb
            >>> import narwhals as nw
            >>> df_native = duckdb.sql(
            ...     "SELECT * FROM VALUES ([2, -1, 1]), ([3, -4, NULL]) df(a)"
            ... )
            >>> df = nw.from_native(df_native)
            >>> df.with_columns(a_sorted=nw.col("a").list.sort())
            ┌─────────────────────────────────┐
            |       Narwhals LazyFrame        |
            |---------------------------------|
            |┌───────────────┬───────────────┐|
            |│       a       │   a_sorted    │|
            |│    int32[]    │    int32[]    │|
            |├───────────────┼───────────────┤|
            |│ [2, -1, 1]    │ [-1, 1, 2]    │|
            |│ [3, -4, NULL] │ [NULL, -4, 3] │|
            |└───────────────┴───────────────┘|
            └─────────────────────────────────┘
        z	list.sortr6   r   )r   r7   r8   s      r   ÚsortzExprListNamespace.sort
  s5   € ð6 �z‰z×&Ñ&ÜÜ×$Ñ$ØØ%Ø%ô	ó
ð 	
r   N)r   r   ÚreturnÚNone)r;   r   )r   r
   r;   r   )r"   r$   r;   r   )r7   Úboolr8   r=   r;   r   )r&   Ú
__module__Ú__qualname__r   r   r   r    r*   r,   r.   r1   r3   r5   r:   © r   r   r   r      sH   „ óóSó:Vó:
ó>&
óPSó.Só2Tó.Vó.Sð2 */À5ö "
r   r   N)Ú
__future__r   Útypingr   r   r   Únarwhals._expression_parsingr   r   Únarwhals.exprr	   Únarwhals.typingr
   r   r   r@   r   r   ú<module>rF      s8   ðÝ "ç 2Ñ 2ç ;áÝ"Ý0á�˜vÔ&€ô^
˜ ™õ ^
r   