
    hB                        S SK Jr  S SKJr  S SKJr  S SKJr  S SKJr  \(       a  S SKJr  \" SSS	9r	 " S
 S\\	   5      r
g)    )annotations)TYPE_CHECKING)Callable)Generic)TypeVar)ExprExprTr   )boundc                  Z    \ rS rSrSS jrSS jrSS jrSS jrSS jrSS jr	SS jr
S	rg
)ExprNameNamespace   c                    Xl         g N_expr)selfexprs     D/var/www/html/env/lib/python3.13/site-packages/narwhals/expr_name.py__init__ExprNameNamespace.__init__   s    
    c                l   ^  T R                   R                  U 4S jT R                   R                  5      $ )aB  Keep the original root name of the expression.

Returns:
    A new expression.

Notes:
    This will undo any previous renaming operations on the expression.
    Due to implementation constraints, this method can only be called as the last
    expression in a chain. Only one name operation per expression will work.

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   > TR                   R                  U 5      R                  R                  5       $ r   )r   _to_compliant_exprnamekeepplxr   s    r   <lambda>(ExprNameNamespace.keep.<locals>.<lambda>&   s#    

55c:??DDFr   r   	__class__	_metadatar   s   `r   r   ExprNameNamespace.keep   s,    & zz##FJJ  
 	
r   c                p   ^ ^ T R                   R                  UU 4S jT R                   R                  5      $ )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.

Returns:
    A new expression.

Notes:
    This will undo any previous renaming operations on the expression.
    Due to implementation constraints, this method can only be called as the last
    expression in a chain. Only one name operation per expression will work.

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                l   > TR                   R                  U 5      R                  R                  T5      $ r   )r   r   r   map)r   functionr   s    r   r   'ExprNameNamespace.map.<locals>.<lambda>B   s%    

55c:??CCHMr   r!   )r   r)   s   ``r   r(   ExprNameNamespace.map*   s,    . zz##MJJ  
 	
r   c                p   ^ ^ T R                   R                  UU 4S jT R                   R                  5      $ )a  Add a prefix to the root column name of the expression.

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

Returns:
    A new expression.

Notes:
    This will undo any previous renaming operations on the expression.
    Due to implementation constraints, this method can only be called as the last
    expression in a chain. Only one name operation per expression will work.

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                l   > TR                   R                  U 5      R                  R                  T5      $ r   )r   r   r   prefix)r   r.   r   s    r   r   *ExprNameNamespace.prefix.<locals>.<lambda>]   %    

55c:??FFvNr   r!   )r   r.   s   ``r   r.   ExprNameNamespace.prefixF   ,    , zz##NJJ  
 	
r   c                p   ^ ^ T R                   R                  U U4S jT R                   R                  5      $ )a  Add a suffix to the root column name of the expression.

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

Returns:
    A new expression.

Notes:
    This will undo any previous renaming operations on the expression.
    Due to implementation constraints, this method can only be called as the last
    expression in a chain. Only one name operation per expression will work.

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                l   > TR                   R                  U 5      R                  R                  T5      $ r   )r   r   r   suffix)r   r   r5   s    r   r   *ExprNameNamespace.suffix.<locals>.<lambda>x   r0   r   r!   )r   r5   s   ``r   r5   ExprNameNamespace.suffixa   r2   r   c                l   ^  T R                   R                  U 4S jT R                   R                  5      $ )a4  Make the root column name lowercase.

Returns:
    A new expression.

Notes:
    This will undo any previous renaming operations on the expression.
    Due to implementation constraints, this method can only be called as the last
    expression in a chain. Only one name operation per expression will work.

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                j   > TR                   R                  U 5      R                  R                  5       $ r   )r   r   r   to_lowercaser   s    r   r   0ExprNameNamespace.to_lowercase.<locals>.<lambda>   #    

55c:??LLNr   r!   r$   s   `r   r:   ExprNameNamespace.to_lowercase|   ,    & zz##NJJ  
 	
r   c                l   ^  T R                   R                  U 4S jT R                   R                  5      $ )a4  Make the root column name uppercase.

Returns:
    A new expression.

Notes:
    This will undo any previous renaming operations on the expression.
    Due to implementation constraints, this method can only be called as the last
    expression in a chain. Only one name operation per expression will work.

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                j   > TR                   R                  U 5      R                  R                  5       $ r   )r   r   r   to_uppercaser   s    r   r   0ExprNameNamespace.to_uppercase.<locals>.<lambda>   r<   r   r!   r$   s   `r   rA   ExprNameNamespace.to_uppercase   r>   r   r   N)r   r	   returnNone)rD   r	   )r)   zCallable[[str], str]rD   r	   )r.   strrD   r	   )r5   rF   rD   r	   )__name__
__module____qualname____firstlineno__r   r   r(   r.   r5   r:   rA   __static_attributes__ r   r   r   r      s%    
0
8
6
6
0
r   r   N)
__future__r   typingr   r   r   r   narwhals.exprr   r	   r   rL   r   r   <module>rP      s8    "     "v&\
 \
r   