§
    q-Phå)  ã                  ó  — d dl mZ d dl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j        e¦  «        5  d dlmZ ddd¦  «         n# 1 swxY w Y   erd dlmZ d dlmZ d d	lmZ dd„Zdd„Zdd„Zdd„Zddœdd„Zddœdd„Zdd„ZdS )é    )ÚannotationsN)ÚTYPE_CHECKING)Úparse_into_list_of_expressions©Ú	wrap_expr)ÚUInt32)ÚIterable)ÚExpr)ÚIntoExprÚexprsúIntoExpr | Iterable[IntoExpr]Úreturnr
   c                 óV   — t          | Ž }t          t          j        |¦  «        ¦  «        S )u  
    Compute the bitwise AND horizontally across columns.

    Parameters
    ----------
    *exprs
        Column(s) to use in the aggregation. Accepts expression input. Strings are
        parsed as column names, other non-expression inputs are parsed as literals.

    Notes
    -----
    `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(
    ...     {
    ...         "a": [False, False, True, True, False, None],
    ...         "b": [False, True, True, None, None, None],
    ...         "c": ["u", "v", "w", "x", "y", "z"],
    ...     }
    ... )
    >>> df.with_columns(all=pl.all_horizontal("a", "b"))
    shape: (6, 4)
    â”Œâ”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”€â”
    â”‚ a     â”† b     â”† c   â”† all   â”‚
    â”‚ ---   â”† ---   â”† --- â”† ---   â”‚
    â”‚ bool  â”† bool  â”† str â”† bool  â”‚
    â•žâ•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•ªâ•â•â•â•â•â•â•â•¡
    â”‚ false â”† false â”† u   â”† false â”‚
    â”‚ false â”† true  â”† v   â”† false â”‚
    â”‚ true  â”† true  â”† w   â”† true  â”‚
    â”‚ true  â”† null  â”† x   â”† null  â”‚
    â”‚ false â”† null  â”† y   â”† false â”‚
    â”‚ null  â”† null  â”† z   â”† null  â”‚
    â””â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”˜
    )r   r   ÚplrÚall_horizontal©r   Úpyexprss     úg/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/polars/functions/aggregation/horizontal.pyr   r      ó(   € õR -¨eÐ4€GÝ•SÔ'¨Ñ0Ô0Ñ1Ô1Ð1ó    c                 óV   — t          | Ž }t          t          j        |¦  «        ¦  «        S )u
  
    Compute the bitwise OR horizontally across columns.

    Parameters
    ----------
    *exprs
        Column(s) to use in the aggregation. Accepts expression input. Strings are
        parsed as column names, other non-expression inputs are parsed as literals.

    Notes
    -----
    `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(
    ...     {
    ...         "a": [False, False, True, True, False, None],
    ...         "b": [False, True, True, None, None, None],
    ...         "c": ["u", "v", "w", "x", "y", "z"],
    ...     }
    ... )
    >>> df.with_columns(any=pl.any_horizontal("a", "b"))
    shape: (6, 4)
    â”Œâ”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”€â”
    â”‚ a     â”† b     â”† c   â”† any   â”‚
    â”‚ ---   â”† ---   â”† --- â”† ---   â”‚
    â”‚ bool  â”† bool  â”† str â”† bool  â”‚
    â•žâ•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•ªâ•â•â•â•â•â•â•â•¡
    â”‚ false â”† false â”† u   â”† false â”‚
    â”‚ false â”† true  â”† v   â”† true  â”‚
    â”‚ true  â”† true  â”† w   â”† true  â”‚
    â”‚ true  â”† null  â”† x   â”† true  â”‚
    â”‚ false â”† null  â”† y   â”† null  â”‚
    â”‚ null  â”† null  â”† z   â”† null  â”‚
    â””â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”˜
    )r   r   r   Úany_horizontalr   s     r   r   r   B   r   r   c                 óV   — t          | Ž }t          t          j        |¦  «        ¦  «        S )u  
    Get the maximum value horizontally across columns.

    Parameters
    ----------
    *exprs
        Column(s) to use in the aggregation. Accepts expression input. Strings are
        parsed as column names, other non-expression inputs are parsed as literals.

    Examples
    --------
    >>> df = pl.DataFrame(
    ...     {
    ...         "a": [1, 8, 3],
    ...         "b": [4, 5, None],
    ...         "c": ["x", "y", "z"],
    ...     }
    ... )
    >>> df.with_columns(max=pl.max_horizontal("a", "b"))
    shape: (3, 4)
    â”Œâ”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”
    â”‚ a   â”† b    â”† c   â”† max â”‚
    â”‚ --- â”† ---  â”† --- â”† --- â”‚
    â”‚ i64 â”† i64  â”† str â”† i64 â”‚
    â•žâ•â•â•â•â•â•ªâ•â•â•â•â•â•â•ªâ•â•â•â•â•â•ªâ•â•â•â•â•â•¡
    â”‚ 1   â”† 4    â”† x   â”† 4   â”‚
    â”‚ 8   â”† 5    â”† y   â”† 8   â”‚
    â”‚ 3   â”† null â”† z   â”† 3   â”‚
    â””â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”˜
    )r   r   r   Úmax_horizontalr   s     r   r   r   o   ó'   € õ> -¨eÐ4€GÝ•SÔ'¨Ñ0Ô0Ñ1Ô1Ð1r   c                 óV   — t          | Ž }t          t          j        |¦  «        ¦  «        S )u  
    Get the minimum value horizontally across columns.

    Parameters
    ----------
    *exprs
        Column(s) to use in the aggregation. Accepts expression input. Strings are
        parsed as column names, other non-expression inputs are parsed as literals.

    Examples
    --------
    >>> df = pl.DataFrame(
    ...     {
    ...         "a": [1, 8, 3],
    ...         "b": [4, 5, None],
    ...         "c": ["x", "y", "z"],
    ...     }
    ... )
    >>> df.with_columns(min=pl.min_horizontal("a", "b"))
    shape: (3, 4)
    â”Œâ”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”
    â”‚ a   â”† b    â”† c   â”† min â”‚
    â”‚ --- â”† ---  â”† --- â”† --- â”‚
    â”‚ i64 â”† i64  â”† str â”† i64 â”‚
    â•žâ•â•â•â•â•â•ªâ•â•â•â•â•â•â•ªâ•â•â•â•â•â•ªâ•â•â•â•â•â•¡
    â”‚ 1   â”† 4    â”† x   â”† 1   â”‚
    â”‚ 8   â”† 5    â”† y   â”† 5   â”‚
    â”‚ 3   â”† null â”† z   â”† 3   â”‚
    â””â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”˜
    )r   r   r   Úmin_horizontalr   s     r   r   r   ’   r   r   T)Úignore_nullsr   Úboolc                óX   — t          |Ž }t          t          j        || ¦  «        ¦  «        S )u  
    Sum all values horizontally across columns.

    Parameters
    ----------
    *exprs
        Column(s) to use in the aggregation. Accepts expression input. Strings are
        parsed as column names, other non-expression inputs are parsed as literals.
    ignore_nulls
        Ignore null values (default).
        If set to `False`, any null value in the input will lead to a null output.

    Examples
    --------
    >>> df = pl.DataFrame(
    ...     {
    ...         "a": [1, 8, 3],
    ...         "b": [4, 5, None],
    ...         "c": ["x", "y", "z"],
    ...     }
    ... )
    >>> df.with_columns(sum=pl.sum_horizontal("a", "b"))
    shape: (3, 4)
    â”Œâ”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”
    â”‚ a   â”† b    â”† c   â”† sum â”‚
    â”‚ --- â”† ---  â”† --- â”† --- â”‚
    â”‚ i64 â”† i64  â”† str â”† i64 â”‚
    â•žâ•â•â•â•â•â•ªâ•â•â•â•â•â•â•ªâ•â•â•â•â•â•ªâ•â•â•â•â•â•¡
    â”‚ 1   â”† 4    â”† x   â”† 5   â”‚
    â”‚ 8   â”† 5    â”† y   â”† 13  â”‚
    â”‚ 3   â”† null â”† z   â”† 3   â”‚
    â””â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”˜
    )r   r   r   Úsum_horizontal©r   r   r   s      r   r!   r!   µ   s*   € õH -¨eÐ4€GÝ•SÔ'¨°Ñ>Ô>Ñ?Ô?Ð?r   c                óX   — t          |Ž }t          t          j        || ¦  «        ¦  «        S )u°  
    Compute the mean of all values horizontally across columns.

    Parameters
    ----------
    *exprs
        Column(s) to use in the aggregation. Accepts expression input. Strings are
        parsed as column names, other non-expression inputs are parsed as literals.
    ignore_nulls
        Ignore null values (default).
        If set to `False`, any null value in the input will lead to a null output.

    Examples
    --------
    >>> df = pl.DataFrame(
    ...     {
    ...         "a": [1, 8, 3],
    ...         "b": [4, 5, None],
    ...         "c": ["x", "y", "z"],
    ...     }
    ... )
    >>> df.with_columns(mean=pl.mean_horizontal("a", "b"))
    shape: (3, 4)
    â”Œâ”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”
    â”‚ a   â”† b    â”† c   â”† mean â”‚
    â”‚ --- â”† ---  â”† --- â”† ---  â”‚
    â”‚ i64 â”† i64  â”† str â”† f64  â”‚
    â•žâ•â•â•â•â•â•ªâ•â•â•â•â•â•â•ªâ•â•â•â•â•â•ªâ•â•â•â•â•â•â•¡
    â”‚ 1   â”† 4    â”† x   â”† 2.5  â”‚
    â”‚ 8   â”† 5    â”† y   â”† 6.5  â”‚
    â”‚ 3   â”† null â”† z   â”† 3.0  â”‚
    â””â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”˜
    )r   r   r   Úmean_horizontalr"   s      r   r$   r$   Ý   s*   € õH -¨eÐ4€GÝ•SÔ(¨°,Ñ?Ô?Ñ@Ô@Ð@r   c                 óÔ   — t          | Ž }d„ |D ¦   «         }t          j        t          j        d¦  «                             t
          ¦  «        d„ |¦  «                             d¦  «        S )ul  
    Cumulatively sum all values horizontally across columns.

    Parameters
    ----------
    *exprs
        Column(s) to use in the aggregation. Accepts expression input. Strings are
        parsed as column names, other non-expression inputs are parsed as literals.

    Examples
    --------
    >>> df = pl.DataFrame(
    ...     {
    ...         "a": [1, 8, 3],
    ...         "b": [4, 5, None],
    ...         "c": ["x", "y", "z"],
    ...     }
    ... )
    >>> df.with_columns(pl.cum_sum_horizontal("a", "b"))
    shape: (3, 4)
    â”Œâ”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”
    â”‚ a   â”† b    â”† c   â”† cum_sum   â”‚
    â”‚ --- â”† ---  â”† --- â”† ---       â”‚
    â”‚ i64 â”† i64  â”† str â”† struct[2] â”‚
    â•žâ•â•â•â•â•â•ªâ•â•â•â•â•â•â•ªâ•â•â•â•â•â•ªâ•â•â•â•â•â•â•â•â•â•â•â•¡
    â”‚ 1   â”† 4    â”† x   â”† {1,5}     â”‚
    â”‚ 8   â”† 5    â”† y   â”† {8,13}    â”‚
    â”‚ 3   â”† null â”† z   â”† {3,null}  â”‚
    â””â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”˜
    c                ó,   — g | ]}t          |¦  «        ‘ŒS © r   )Ú.0Úes     r   ú
<listcomp>z&cum_sum_horizontal.<locals>.<listcomp>%  s   € Ð3Ð3Ð3 a•Y˜q‘\”\Ð3Ð3Ð3r   r   c                ó   — | |z   S )Nr'   )ÚaÚbs     r   ú<lambda>z$cum_sum_horizontal.<locals>.<lambda>(  s
   € ¸!¸a¹%€ r   Úcum_sum)r   ÚFÚcum_foldÚlitÚcastr   Úalias)r   r   Úexprs_wrappeds      r   Úcum_sum_horizontalr6     sd   € õ> -¨eÐ4€GØ3Ð3¨7Ð3Ñ3Ô3€Mõ Œ:•a”e˜A‘h”h—m’m¥FÑ+Ô+Ð-?Ð-?ÀÑOÔO×UÒUØñô ð r   )r   r   r   r
   )r   r   r   r   r   r
   )Ú
__future__r   Ú
contextlibÚtypingr   Úpolars.functionsÚ	functionsr0   Úpolars._utils.parser   Úpolars._utils.wrapr   Úpolars.datatypesr   ÚsuppressÚImportErrorÚpolars.polarsÚpolarsr   Úcollections.abcr	   r
   Úpolars._typingr   r   r   r   r   r!   r$   r6   r'   r   r   ú<module>rE      s  ðØ "Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ø  Ð  Ð  Ð  Ð  Ð  à Ð Ð Ð Ð Ð Ø >Ð >Ð >Ð >Ð >Ð >Ø (Ð (Ð (Ð (Ð (Ð (Ø #Ð #Ð #Ð #Ð #Ð #à€ZÔ˜Ñ%Ô%ð  ð  ØÐÐÐÐÐð ð  ð  ñ  ô  ð  ð  ð  ð  ð  ð  øøøð  ð  ð  ð  ð ð (Ø(Ð(Ð(Ð(Ð(Ð(àÐÐÐÐÐØ'Ð'Ð'Ð'Ð'Ð'ð*2ð *2ð *2ð *2ðZ*2ð *2ð *2ð *2ðZ 2ð  2ð  2ð  2ðF 2ð  2ð  2ð  2ðH AEð%@ð %@ð %@ð %@ð %@ð %@ðR AEð%Að %Að %Að %Að %Að %AðP%ð %ð %ð %ð %ð %s   ¹AÁAÁA