
    ei                    X    d dl mZ d dlmZmZ d dlmZ erd dlmZ  G d dee         Zy)    )annotations)TYPE_CHECKINGGeneric)SeriesT)NonNestedLiteralc                  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)SeriesListNamespacec                    || _         y )N)_narwhals_series)selfseriess     V/var/www/html/glpi_dashboard/venv/lib/python3.12/site-packages/narwhals/series_list.py__init__zSeriesListNamespace.__init__   s
     &    c                    | j                   j                  | j                   j                  j                  j	                               S )aM  Return the number of elements in each list.

        Null values count towards the total.

        Examples:
            >>> import pyarrow as pa
            >>> import narwhals as nw
            >>> s_native = pa.chunked_array([[[1, 2], [3, 4, None], None, []]])
            >>> s = nw.from_native(s_native, series_only=True)
            >>> s.list.len().to_native()  # doctest: +ELLIPSIS
            <pyarrow.lib.ChunkedArray object at ...>
            [
              [
                2,
                3,
                null,
                0
              ]
            ]
        )r   _with_compliant_compliant_serieslistlenr   s    r   r   zSeriesListNamespace.len   s;    * $$44!!3388<<>
 	
r   c                    | j                   j                  | j                   j                  j                  j	                               S )as  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
            >>> s_native = pl.Series([[1, 1, 2], [3, 3, None], None, []])
            >>> s = nw.from_native(s_native, series_only=True)
            >>> s.list.unique().to_native()  # doctest: +NORMALIZE_WHITESPACE
            shape: (4,)
            Series: '' [list[i64]]
            [
               [1, 2]
               [null, 3]
               null
               []
            ]
        )r   r   r   r   uniquer   s    r   r   zSeriesListNamespace.unique(   s;    ( $$44!!3388??A
 	
r   c                    | j                   j                  | j                   j                  j                  j	                  |            S )aF  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
            >>> s_native = pl.Series([[1, 2], None, []])
            >>> s = nw.from_native(s_native, series_only=True)
            >>> s.list.contains(1).to_native()  # doctest: +NORMALIZE_WHITESPACE
            shape: (3,)
            Series: '' [bool]
            [
                    true
                    null
                    false
            ]
        )r   r   r   r   contains)r   items     r   r   zSeriesListNamespace.contains@   s=    ( $$44!!3388AA$G
 	
r   c                &   t        |t              s$dt        |      j                   d}t	        |      |dk  rd| d}t        |      | j                  j                  | j                  j                  j                  j                  |            S )a  Return the value by index in each list.

        Negative indices are not accepted.

        Examples:
            >>> import polars as pl
            >>> import narwhals as nw
            >>> s_native = pl.Series([[1, 2], [3, 4, None], [None, 5]])
            >>> s = nw.from_native(s_native, series_only=True)
            >>> s.list.get(1).to_native()  # doctest: +NORMALIZE_WHITESPACE
            shape: (3,)
            Series: '' [i64]
            [
                    2
                    4
                    5
            ]
        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.)
isinstanceinttype__name__	TypeError
ValueErrorr   r   r   r   get)r   indexmsgs      r   r#   zSeriesListNamespace.getX   s    & %%9$u+:N:N9OzZ  C. 195'!YZCS/!$$44!!3388<<UC
 	
r   c                    | j                   j                  | j                   j                  j                  j	                               S )a  Compute the min value of the lists in the array.

        Examples:
            >>> import polars as pl
            >>> import narwhals as nw
            >>> s_native = pl.Series([[1], [3, 4, None]])
            >>> s = nw.from_native(s_native, series_only=True)
            >>> s.list.min().to_native()  # doctest: +NORMALIZE_WHITESPACE
            shape: (2,)
            Series: '' [i64]
            [
                    1
                    3
            ]
        )r   r   r   r   minr   s    r   r'   zSeriesListNamespace.miny   ;      $$44!!3388<<>
 	
r   c                    | j                   j                  | j                   j                  j                  j	                               S )a  Compute the max value of the lists in the array.

        Examples:
            >>> import pyarrow as pa
            >>> import narwhals as nw
            >>> s_native = pa.chunked_array([[[1], [3, 4, None]]])
            >>> s = nw.from_native(s_native, series_only=True)
            >>> s.list.max().to_native()  # doctest: +ELLIPSIS
            <pyarrow.lib.ChunkedArray object at ...>
            [
              [
                1,
                4
              ]
            ]
        )r   r   r   r   maxr   s    r   r*   zSeriesListNamespace.max   s;    " $$44!!3388<<>
 	
r   c                    | j                   j                  | j                   j                  j                  j	                               S )a  Compute the mean value of the lists in the array.

        Examples:
            >>> import polars as pl
            >>> import narwhals as nw
            >>> s_native = pl.Series([[1], [3, 4, None]])
            >>> s = nw.from_native(s_native, series_only=True)
            >>> s.list.mean().to_native()  # doctest: +NORMALIZE_WHITESPACE
            shape: (2,)
            Series: '' [f64]
            [
                    1.0
                    3.5
            ]
        )r   r   r   r   meanr   s    r   r,   zSeriesListNamespace.mean   s;      $$44!!3388==?
 	
r   c                    | j                   j                  | j                   j                  j                  j	                               S )a  Compute the median value of the lists in the array.

        Examples:
            >>> import pyarrow as pa
            >>> import narwhals as nw
            >>> s_native = pa.chunked_array([[[1], [3, 4, None]]])
            >>> s = nw.from_native(s_native, series_only=True)
            >>> s.list.median().to_native()  # doctest: +ELLIPSIS
            <pyarrow.lib.ChunkedArray object at ...>
            [
              [
                1,
                3
              ]
            ]
        )r   r   r   r   medianr   s    r   r.   zSeriesListNamespace.median   s;    " $$44!!3388??A
 	
r   c                    | j                   j                  | j                   j                  j                  j	                               S )a  Compute the sum value of the lists in the array.

        Examples:
            >>> import polars as pl
            >>> import narwhals as nw
            >>> s_native = pl.Series([[1], [3, 4, None]])
            >>> s = nw.from_native(s_native, series_only=True)
            >>> s.list.sum().to_native()  # doctest: +NORMALIZE_WHITESPACE
            shape: (2,)
            Series: '' [i64]
            [
                    1
                    7
            ]
        )r   r   r   r   sumr   s    r   r0   zSeriesListNamespace.sum   r(   r   F
descending
nulls_lastc                   | j                   j                  | j                   j                  j                  j	                  ||            S )a^  Sort the lists of the series.

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

        Examples:
            >>> import polars as pl
            >>> import narwhals as nw
            >>> s_native = pl.Series([[2, -1, 1], [3, -4, None]])
            >>> s = nw.from_native(s_native, series_only=True)
            >>> s.list.sort().to_native()  # doctest: +NORMALIZE_WHITESPACE
            shape: (2,)
            Series: '' [list[i64]]
            [
                    [-1, 1, 2]
                    [null, -4, 3]
            ]
        r1   )r   r   r   r   sort)r   r2   r3   s      r   r5   zSeriesListNamespace.sort   sG    ( $$44!!3388==%* > 
 	
r   N)r   r   returnNone)r6   r   )r   r   r6   r   )r$   r   r6   r   )r2   boolr3   r8   r6   r   )r    
__module____qualname__r   r   r   r   r#   r'   r*   r,   r.   r0   r5    r   r   r	   r	      sA    '
2
0
0
B
(
*
(
*
( */5 
r   r	   N)	
__future__r   typingr   r   narwhals.typingr   r   r	   r;   r   r   <module>r?      s'    " ) #0l
''* l
r   