§
    cŠtj¦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dS )é    )Úannotations)ÚTYPE_CHECKINGÚGenericÚTypeVar)ÚExprKindÚExprNode)ÚExpr)ÚNonNestedLiteralÚExprTr	   )Úboundc                  ón   — 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dS )ÚExprListNamespaceÚexprr   ÚreturnÚNonec                ó   — || _         d S )N)Ú_expr)Úselfr   s     úP/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/narwhals/expr_list.pyÚ__init__zExprListNamespace.__init__   s   € ØˆŒ
ˆ
ˆ
ó    c                óf   — | 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×&Ò&¥xµÔ0DÀjÑ'QÔ'QÑRÔRÐRr   c                óf   — | 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×&Ò&¥xµÔ0DÀmÑ'TÔ'TÑUÔUÐUr   Úitemr
   c                ó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)r    r   )r   r    s     r   ÚcontainszExprListNamespace.containsL   s3   € ð6 Œz×&Ò&Ý•XÔ)¨?ÀÐFÑFÔFñ
ô 
ð 	
r   ÚindexÚintc                ó  — t          |t          ¦  «        s'dt          |¦  «        j        › d�}t	          |¦  «        ‚|dk     rd|› d�}t          |¦  «        ‚| 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)r#   )Ú
isinstancer$   ÚtypeÚ__name__Ú	TypeErrorÚ
ValueErrorr   r   r   r   r   )r   r#   Úmsgs      r   ÚgetzExprListNamespace.getk   s”   € õ4 ˜%¥Ñ%Ô%ð 	!àZ½$¸u¹+¼+Ô:NÐZÐZÐZð õ ˜C‘.”.Ð à�1Š9ˆ9ØZ˜5ÐZÐZÐZˆCÝ˜S‘/”/Ð!àŒz×&Ò&Ý•XÔ)¨:¸UÐCÑCÔCñ
ô 
ð 	
r   c                óf   — | 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×&Ò&¥xµÔ0DÀjÑ'QÔ'QÑRÔRÐRr   c                óf   — | 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×&Ò&¥xµÔ0DÀjÑ'QÔ'QÑRÔRÐRr   c                óf   — | 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×&Ò&¥xµÔ0DÀkÑ'RÔ'RÑSÔSÐSr   c                óf   — | 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×&Ò&¥xµÔ0DÀmÑ'TÔ'TÑUÔUÐUr   c                óf   — | 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ñ   r1   r   F©Ú
descendingÚ
nulls_lastr9   Úboolr:   c               ól   — | 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.sortr8   r   )r   r9   r:   s      r   ÚsortzExprListNamespace.sort
  s?   € ð6 Œz×&Ò&ÝÝÔ$ØØ%Ø%ð	ñ ô ñ
ô 
ð 	
r   N)r   r   r   r   )r   r   )r    r
   r   r   )r#   r$   r   r   )r9   r;   r:   r;   r   r   )r(   Ú
__module__Ú__qualname__r   r   r   r"   r,   r.   r0   r3   r5   r7   r=   © r   r   r   r      s  € € € € € ðð ð ð ðSð Sð Sð Sð:Vð Vð Vð Vð:
ð 
ð 
ð 
ð>&
ð &
ð &
ð &
ðPSð Sð Sð Sð.Sð Sð Sð Sð2Tð Tð Tð Tð.Vð Vð Vð Vð.Sð Sð Sð 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      sÏ   ðØ "Ð "Ð "Ð "Ð "Ð "à 2Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2à ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;àð 1Ø"Ð"Ð"Ð"Ð"Ð"Ø0Ð0Ð0Ð0Ð0Ð0àˆ�˜vÐ&Ñ&Ô&€ð^
ð ^
ð ^
ð ^
ð ^
˜ œñ ^
ô ^
ð ^
ð ^
ð ^
r   