Ë
    z�hB  ã                  ó€   — 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  edd¬	«      Z	 G d
„ dee	   «      Z
y)é    )Úannotations)ÚTYPE_CHECKING)ÚCallable)ÚGeneric)ÚTypeVar)ÚExprÚExprTr   )Úboundc                  óD   — 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	y)ÚExprNameNamespacec                ó   — || _         y ©N)Ú_expr)ÚselfÚexprs     úP/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/narwhals/expr_name.pyÚ__init__zExprNameNamespace.__init__   s	   € Øˆ�
ó    c                ój   ‡ — ‰ j                   j                  ˆ f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                   j                  | «      j                  j                  «       S r   )r   Ú_to_compliant_exprÚnameÚkeep©Úplxr   s    €r   ú<lambda>z(ExprNameNamespace.keep.<locals>.<lambda>&   s%   ø€ ˜Ÿ
™
×5Ñ5°cÓ:×?Ñ?×DÑDÓF€ r   ©r   Ú	__class__Ú	_metadata©r   s   `r   r   zExprNameNamespace.keep   s,   ø€ ð& �z‰z×#Ñ#ÛFØ�J‰J× Ñ ó
ð 	
r   c                ón   ‡ ‡— ‰ j                   j                  ˆˆ f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                ól   •— ‰j                   j                  | «      j                  j                  ‰«      S r   )r   r   r   Úmap)r   Úfunctionr   s    €€r   r   z'ExprNameNamespace.map.<locals>.<lambda>B   s'   ø€ ˜Ÿ
™
×5Ñ5°cÓ:×?Ñ?×CÑCÀHÓM€ r   r   )r   r$   s   ``r   r#   zExprNameNamespace.map*   s,   ù€ ð. �z‰z×#Ñ#ÜMØ�J‰J× Ñ ó
ð 	
r   c                ón   ‡ ‡— ‰ j                   j                  ˆˆ fd„‰ j                   j                  «      S )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   •— ‰j                   j                  | «      j                  j                  ‰«      S r   )r   r   r   Úprefix)r   r'   r   s    €€r   r   z*ExprNameNamespace.prefix.<locals>.<lambda>]   ó'   ø€ ˜Ÿ
™
×5Ñ5°cÓ:×?Ñ?×FÑFÀvÓN€ r   r   )r   r'   s   ``r   r'   zExprNameNamespace.prefixF   ó,   ù€ ð, �z‰z×#Ñ#ÜNØ�J‰J× Ñ ó
ð 	
r   c                ón   ‡ ‡— ‰ j                   j                  ˆ ˆf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                ól   •— ‰j                   j                  | «      j                  j                  ‰«      S r   )r   r   r   Úsuffix)r   r   r,   s    €€r   r   z*ExprNameNamespace.suffix.<locals>.<lambda>x   r(   r   r   )r   r,   s   ``r   r,   zExprNameNamespace.suffixa   r)   r   c                ój   ‡ — ‰ j                   j                  ˆ fd„‰ j                   j                  «      S )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                ój   •— ‰j                   j                  | «      j                  j                  «       S r   )r   r   r   Úto_lowercaser   s    €r   r   z0ExprNameNamespace.to_lowercase.<locals>.<lambda>�   ó%   ø€ ˜Ÿ
™
×5Ñ5°cÓ:×?Ñ?×LÑLÓN€ r   r   r    s   `r   r/   zExprNameNamespace.to_lowercase|   ó,   ø€ ð& �z‰z×#Ñ#ÛNØ�J‰J× Ñ ó
ð 	
r   c                ój   ‡ — ‰ j                   j                  ˆ fd„‰ j                   j                  «      S )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                ój   •— ‰j                   j                  | «      j                  j                  «       S r   )r   r   r   Úto_uppercaser   s    €r   r   z0ExprNameNamespace.to_uppercase.<locals>.<lambda>¨   r0   r   r   r    s   `r   r4   zExprNameNamespace.to_uppercase”   r1   r   N)r   r	   ÚreturnÚNone)r5   r	   )r$   zCallable[[str], str]r5   r	   )r'   Ústrr5   r	   )r,   r7   r5   r	   )
Ú__name__Ú
__module__Ú__qualname__r   r   r#   r'   r,   r/   r4   © r   r   r   r      s%   „ óó
ó0
ó8
ó6
ó6
ô0
r   r   N)Ú
__future__r   Útypingr   r   r   r   Únarwhals.exprr   r	   r   r;   r   r   ú<module>r?      s8   ðÝ "å  Ý Ý Ý áÝ"á�˜vÔ&€ô\
˜ ™õ \
r   