o
    L¾±hÎ  ã                   @  sT   d dl mZ d dl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ÚGenericÚTypeVar)ÚExprÚExprTr   )Úboundc                   @  s    e Zd Zddd„Zdd	d
„ZdS )ÚExprStructNamespaceÚexprr   ÚreturnÚNonec                 C  s
   || _ d S ©N)Ú_expr)Úselfr
   © r   úU/var/www/html/Persson_Maskin/env/lib/python3.10/site-packages/narwhals/expr_struct.pyÚ__init__   s   
zExprStructNamespace.__init__ÚnameÚstrc                   s   ˆj  ‡ ‡fdd„¡S )uæ  Retrieve a Struct field as a new expression.

        Arguments:
            name: Name of the struct field to retrieve.

        Examples:
            >>> import polars as pl
            >>> import narwhals as nw
            >>> df_native = pl.DataFrame(
            ...     {"user": [{"id": "0", "name": "john"}, {"id": "1", "name": "jane"}]}
            ... )
            >>> df = nw.from_native(df_native)
            >>> df.with_columns(name=nw.col("user").struct.field("name"))
            â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”
            |  Narwhals DataFrame   |
            |-----------------------|
            |shape: (2, 2)          |
            |â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”|
            |â”‚ user         â”† name â”‚|
            |â”‚ ---          â”† ---  â”‚|
            |â”‚ struct[2]    â”† str  â”‚|
            |â•žâ•â•â•â•â•â•â•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•¡|
            |â”‚ {"0","john"} â”† john â”‚|
            |â”‚ {"1","jane"} â”† jane â”‚|
            |â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”˜|
            â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”˜
        c                   s   ˆj  | ¡j ˆ ¡S r   )r   Ú_to_compliant_exprÚstructÚfield)Úplx©r   r   r   r   Ú<lambda>,   s    z+ExprStructNamespace.field.<locals>.<lambda>)r   Ú_with_elementwise)r   r   r   r   r   r      s   ÿzExprStructNamespace.fieldN)r
   r   r   r   )r   r   r   r   )Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   r	      s    
r	   N)
Ú
__future__r   Útypingr   r   r   Únarwhals.exprr   r   r	   r   r   r   r   Ú<module>   s    