o
    Lh                     @  sX   d dl mZ d dlmZmZmZmZ erd dlmZ edddZ	G dd dee	 Z
d	S )
    )annotations)TYPE_CHECKINGCallableGenericTypeVar)ExprExprTr   )boundc                   @  sR   e Zd ZdddZdddZdddZdddZdddZdddZdddZ	dS )ExprNameNamespaceexprr   returnNonec                 C  s
   || _ d S N)_expr)selfr    r   S/var/www/html/Persson_Maskin/env/lib/python3.10/site-packages/narwhals/expr_name.py__init__   s   
zExprNameNamespace.__init__c                       j  fddS )a  Keep the original root name of the expression.

        Notes:
            For Polars versions prior to 1.32, this will undo any previous renaming operations on the expression.

        Examples:
            >>> import pandas as pd
            >>> import narwhals as nw
            >>> df_native = pd.DataFrame({"foo": [1, 2], "BAR": [4, 5]})
            >>> df = nw.from_native(df_native)
            >>> df.select(nw.col("foo").alias("alias_for_foo").name.keep()).columns
            ['foo']
        c                       j | j S r   )r   _to_compliant_exprnamekeepplxr   r   r   <lambda>       z(ExprNameNamespace.keep.<locals>.<lambda>r   _with_elementwiser   r   r   r   r         
zExprNameNamespace.keepfunctionCallable[[str], str]c                      j  fddS )a  Rename the output of an expression by mapping a function over the root name.

        Arguments:
            function: Function that maps a root name to a new name.

        Notes:
            For Polars versions prior to 1.32, this will undo any previous renaming operations on the expression.

        Examples:
            >>> import pandas as pd
            >>> import narwhals as nw
            >>> df_native = pd.DataFrame({"foo": [1, 2], "BAR": [4, 5]})
            >>> df = nw.from_native(df_native)
            >>> renaming_func = lambda s: s[::-1]  # reverse column name
            >>> df.select(nw.col("foo", "BAR").name.map(renaming_func)).columns
            ['oof', 'RAB']
        c                      j | j S r   )r   r   r   mapr   r!   r   r   r   r   4       z'ExprNameNamespace.map.<locals>.<lambda>r   )r   r!   r   r&   r   r%   !   s   zExprNameNamespace.mapprefixstrc                   r#   )aj  Add a prefix to the root column name of the expression.

        Arguments:
            prefix: Prefix to add to the root column name.

        Notes:
            For Polars versions prior to 1.32, this will undo any previous renaming operations on the expression.

        Examples:
            >>> import polars as pl
            >>> import narwhals as nw
            >>> df_native = pl.DataFrame({"foo": [1, 2], "BAR": [4, 5]})
            >>> df = nw.from_native(df_native)
            >>> df.select(nw.col("foo", "BAR").name.prefix("with_prefix")).columns
            ['with_prefixfoo', 'with_prefixBAR']
        c                   r$   r   )r   r   r   r(   r   r(   r   r   r   r   I   r'   z*ExprNameNamespace.prefix.<locals>.<lambda>r   )r   r(   r   r*   r   r(   7      zExprNameNamespace.prefixsuffixc                   s    j  fddS )am  Add a suffix to the root column name of the expression.

        Arguments:
            suffix: Suffix to add to the root column name.

        Notes:
            For Polars versions prior to 1.32, this will undo any previous renaming operations on the expression.

        Examples:
            >>> import polars as pl
            >>> import narwhals as nw
            >>> df_native = pl.DataFrame({"foo": [1, 2], "BAR": [4, 5]})
            >>> df = nw.from_native(df_native)
            >>> df.select(nw.col("foo", "BAR").name.suffix("_with_suffix")).columns
            ['foo_with_suffix', 'BAR_with_suffix']
        c                   s    j | jS r   )r   r   r   r,   r   r   r,   r   r   r   ^   r'   z*ExprNameNamespace.suffix.<locals>.<lambda>r   r-   r   r-   r   r,   L   r+   zExprNameNamespace.suffixc                   r   )a  Make the root column name lowercase.

        Notes:
            For Polars versions prior to 1.32, this will undo any previous renaming operations on the expression.

        Examples:
            >>> import pyarrow as pa
            >>> import narwhals as nw
            >>> df_native = pa.table({"foo": [1, 2], "BAR": [4, 5]})
            >>> df = nw.from_native(df_native)
            >>> df.select(nw.col("foo", "BAR").name.to_lowercase()).columns
            ['foo', 'bar']
        c                   r   r   )r   r   r   to_lowercaser   r   r   r   r   p   r   z0ExprNameNamespace.to_lowercase.<locals>.<lambda>r   r   r   r   r   r.   a   r    zExprNameNamespace.to_lowercasec                   r   )a  Make the root column name uppercase.

        Notes:
            For Polars versions prior to 1.32, this will undo any previous renaming operations on the expression.

        Examples:
            >>> import pyarrow as pa
            >>> import narwhals as nw
            >>> df_native = pa.table({"foo": [1, 2], "BAR": [4, 5]})
            >>> df = nw.from_native(df_native)
            >>> df.select(nw.col("foo", "BAR").name.to_uppercase()).columns
            ['FOO', 'BAR']
        c                   r   r   )r   r   r   to_uppercaser   r   r   r   r      r   z0ExprNameNamespace.to_uppercase.<locals>.<lambda>r   r   r   r   r   r/   s   r    zExprNameNamespace.to_uppercaseN)r   r   r   r   )r   r   )r!   r"   r   r   )r(   r)   r   r   )r,   r)   r   r   )
__name__
__module____qualname__r   r   r%   r(   r,   r.   r/   r   r   r   r   r
      s    





r
   N)
__future__r   typingr   r   r   r   narwhals.exprr   r   r
   r   r   r   r   <module>   s    