o
    @g                     @  s|   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r,d dlmZ 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)Self)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selfr   exprr	   returnNonec                 C  s
   || _ d S N)_expr)r   r    r   Y/var/www/html/development/chatbot/venv/lib/python3.10/site-packages/narwhals/expr_name.py__init__   s   
zExprNameNamespace.__init__c                       j  fdd j jS )a  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 | j S r   )r   _to_compliant_exprnamekeepplxr   r   r   <lambda>(       z(ExprNameNamespace.keep.<locals>.<lambda>r   	__class__	_metadatar   r   r   r   r         
zExprNameNamespace.keepfunctionCallable[[str], str]c                      j  fddj jS )at  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                      j | j S r   )r   r   r   mapr   r#   r   r   r   r   D       z'ExprNameNamespace.map.<locals>.<lambda>r   )r   r#   r   r(   r   r'   ,   s   zExprNameNamespace.mapprefixstrc                   r%   )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                   r&   r   )r   r   r   r*   r   r*   r   r   r   r   _   r)   z*ExprNameNamespace.prefix.<locals>.<lambda>r   )r   r*   r   r,   r   r*   H      zExprNameNamespace.prefixsuffixc                   s    j  fdd j jS )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                   s    j | jS r   )r   r   r   r.   r   r   r.   r   r   r   z   r)   z*ExprNameNamespace.suffix.<locals>.<lambda>r   r/   r   r/   r   r.   c   r-   zExprNameNamespace.suffixc                   r   )a  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                   r   r   )r   r   r   to_lowercaser   r   r   r   r      r   z0ExprNameNamespace.to_lowercase.<locals>.<lambda>r   r   r   r   r   r0   ~   r"   zExprNameNamespace.to_lowercasec                   r   )a  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                   r   r   )r   r   r   to_uppercaser   r   r   r   r      r   z0ExprNameNamespace.to_uppercase.<locals>.<lambda>r   r   r   r   r   r1      r"   zExprNameNamespace.to_uppercaseN)r   r   r   r	   r   r   )r   r   r   r	   )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.   r0   r1   r   r   r   r   r      s    





r   N)
__future__r   typingr   r   r   r   typing_extensionsr   narwhals.exprr   r	   r   r   r   r   r   <module>   s    