Ë
    	êñiÉ9  ã                  óø   — d dl mZ d dlmZmZmZ 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 d dlmZ er:d dlZd d	lmZ d d
lmZ d dlmZ d dlmZmZ ej:                  dk\  rd dlm
Z
 nd dlm
Z
  G d„ d«      Z y)é    )Úannotations)ÚTYPE_CHECKINGÚLiteralÚoverloadN)Ú
deprecated)Úserialize_polars_object)Údisplay_dot_graph)Ú	wrap_expr)ÚComputeError)ÚIOBase)ÚPath)ÚExpr)Ú
SchemaDictÚSerializationFormat)é   é   c                  ó@  — e Zd ZdZdZd1d„Zd2d„Zd2d„Zd3d„Zd4d„Z	d4d„Z
d4d	„Zd4d
„Zd5d„Zd5d„Zd5d„Zddœd6d„Zddœd6d„Zeddœd7d„«       Zed8d„«       Zddœd9d„Zddœd:d„Zd;d„Zd<d„Zd<d„Zd=d„Ze	 d>ddœ	 	 	 	 	 d?d „«       Zed>d@d!„«       Zeddœ	 	 	 	 	 dAd"„«       Z	 dBd#dœ	 	 	 	 	 dCd$„Zed>dDd%„«       ZedEd&„«       Z ed'«      dBdFd(„«       Zeddd)œ	 	 	 	 	 dGd*„«       Zeddœ	 	 	 	 	 dHd+„«       Zddd)œ	 	 	 	 	 dId,„Zdddd-dd.œ	 	 	 	 	 	 	 	 	 	 	 dJd/„ZdKd0„Zy)LÚExprMetaNameSpacez*Namespace for expressions on a meta level.Úmetac                ó&   — |j                   | _         y ©N)Ú_pyexpr©ÚselfÚexprs     úR/var/www/pod-logistic/pod-ai/venv/lib/python3.12/site-packages/polars/expr/meta.pyÚ__init__zExprMetaNameSpace.__init__   s   € Ø—|‘|ˆ�ó    c                óN   — t        | j                  «      j                  «       › d�S ©Nz.meta)r
   r   Ú__str__©r   s    r   r!   zExprMetaNameSpace.__str__"   s"   € Ü˜DŸL™LÓ)×1Ñ1Ó3Ð4°EÐ:Ð:r   c                óN   — t        | j                  «      j                  «       › d�S r    )r
   r   Ú__repr__r"   s    r   r$   zExprMetaNameSpace.__repr__%   s"   € Ü˜DŸL™LÓ)×2Ñ2Ó4Ð5°UÐ;Ð;r   c                ó6   — | j                   j                  «       S r   )r   Ú__hash__r"   s    r   r&   zExprMetaNameSpace.__hash__(   s   € Ø�|‰|×$Ñ$Ó&Ð&r   c                óL   — | j                   j                  |j                   «      S r   ©r   Úmeta_eq©r   Úothers     r   Ú__eq__zExprMetaNameSpace.__eq__+   s   € Ø�|‰|×#Ñ# E§M¡MÓ2Ð2r   c                ó   — | |k(   S r   © r*   s     r   Ú__ne__zExprMetaNameSpace.__ne__.   s   € Ø˜5‘=Ð Ð r   c                óL   — | j                   j                  |j                   «      S )aX  
        Indicate if this expression is the same as another expression.

        Examples
        --------
        >>> foo_bar = pl.col("foo").alias("bar")
        >>> foo = pl.col("foo")
        >>> foo_bar.meta.eq(foo)
        False
        >>> foo_bar2 = pl.col("foo").alias("bar")
        >>> foo_bar.meta.eq(foo_bar2)
        True
        r(   r*   s     r   ÚeqzExprMetaNameSpace.eq1   s   € ð �|‰|×#Ñ# E§M¡MÓ2Ð2r   c                ó&   — | j                  |«       S )a\  
        Indicate if this expression is NOT the same as another expression.

        Examples
        --------
        >>> foo_bar = pl.col("foo").alias("bar")
        >>> foo = pl.col("foo")
        >>> foo_bar.meta.ne(foo)
        True
        >>> foo_bar2 = pl.col("foo").alias("bar")
        >>> foo_bar.meta.ne(foo_bar2)
        False
        )r1   r*   s     r   ÚnezExprMetaNameSpace.neA   s   € ð —7‘7˜5“>Ð!Ð!r   c                ó6   — | j                   j                  «       S )zá
        Indicate if this expression expands into multiple expressions.

        Examples
        --------
        >>> e = pl.col(["a", "b"]).name.suffix("_foo")
        >>> e.meta.has_multiple_outputs()
        True
        )r   Úmeta_has_multiple_outputsr"   s    r   Úhas_multiple_outputsz&ExprMetaNameSpace.has_multiple_outputsQ   s   € ð �|‰|×5Ñ5Ó7Ð7r   c                ó6   — | j                   j                  «       S )aq  
        Indicate if this expression is a basic (non-regex) unaliased column.

        Examples
        --------
        >>> e = pl.col("foo")
        >>> e.meta.is_column()
        True
        >>> e = pl.col("foo") * pl.col("bar")
        >>> e.meta.is_column()
        False
        >>> e = pl.col(r"^col.*\d+$")
        >>> e.meta.is_column()
        False
        )r   Úmeta_is_columnr"   s    r   Ú	is_columnzExprMetaNameSpace.is_column]   s   € ð  �|‰|×*Ñ*Ó,Ð,r   c                ó6   — | j                   j                  «       S )zè
        Indicate if this expression expands to columns that match a regex pattern.

        Examples
        --------
        >>> e = pl.col("^.*$").name.prefix("foo_")
        >>> e.meta.is_regex_projection()
        True
        )r   Úmeta_is_regex_projectionr"   s    r   Úis_regex_projectionz%ExprMetaNameSpace.is_regex_projectiono   s   € ð �|‰|×4Ñ4Ó6Ð6r   F)Úallow_aliasingc               ó8   — | j                   j                  |«      S )az  
        Indicate if this expression only selects columns (optionally with aliasing).

        This can include bare columns, columns matched by regex or dtype, selectors
        and exclude ops, and (optionally) column/expression aliasing.

        .. versionadded:: 0.20.30

        Parameters
        ----------
        allow_aliasing
            If False (default), any aliasing is not considered to be column selection.
            Set True to allow for column selection that also includes aliasing.

        Examples
        --------
        >>> import polars.selectors as cs
        >>> e = pl.col("foo")
        >>> e.meta.is_column_selection()
        True
        >>> e = pl.col("foo").alias("bar")
        >>> e.meta.is_column_selection()
        False
        >>> e.meta.is_column_selection(allow_aliasing=True)
        True
        >>> e = pl.col("foo") * pl.col("bar")
        >>> e.meta.is_column_selection()
        False
        >>> e = cs.starts_with("foo")
        >>> e.meta.is_column_selection()
        True
        >>> e = cs.starts_with("foo").exclude("foo!")
        >>> e.meta.is_column_selection()
        True
        )r   Úmeta_is_column_selection©r   r=   s     r   Úis_column_selectionz%ExprMetaNameSpace.is_column_selection{   s   € ðH �|‰|×4Ñ4°^ÓDÐDr   c               ó8   — | j                   j                  |«      S )a•  
        Indicate if this expression is a literal value (optionally aliased).

        .. versionadded:: 1.14

        Parameters
        ----------
        allow_aliasing
            If False (default), only a bare literal will match.
            Set True to also allow for aliased literals.

        Examples
        --------
        >>> from datetime import datetime
        >>> e = pl.lit(123)
        >>> e.meta.is_literal()
        True
        >>> e = pl.lit(987.654321).alias("foo")
        >>> e.meta.is_literal()
        False
        >>> e = pl.lit(datetime.now()).alias("bar")
        >>> e.meta.is_literal(allow_aliasing=True)
        True
        )r   Úmeta_is_literalr@   s     r   Ú
is_literalzExprMetaNameSpace.is_literal¡   s   € ð2 �|‰|×+Ñ+¨NÓ;Ð;r   T)Úraise_if_undeterminedc                ó   — y r   r.   ©r   rE   s     r   Úoutput_namezExprMetaNameSpace.output_name¼   s   € ØRUr   c                ó   — y r   r.   rG   s     r   rH   zExprMetaNameSpace.output_name¿   s   € ØSVr   c               ó\   — 	 | j                   j                  «       S # t        $ r |sY y‚ w xY w)aa  
        Get the column name that this expression would produce.

        It may not always be possible to determine the output name as that can depend
        on the schema of the context; in that case this will raise `ComputeError` if
        `raise_if_undetermined` is True (the default), or `None` otherwise.

        Examples
        --------
        >>> e = pl.col("foo") * pl.col("bar")
        >>> e.meta.output_name()
        'foo'
        >>> e_filter = pl.col("foo").filter(pl.col("bar") == 13)
        >>> e_filter.meta.output_name()
        'foo'
        >>> e_sum_over = pl.sum("foo").over("groups")
        >>> e_sum_over.meta.output_name()
        'foo'
        >>> e_sum_slice = pl.sum("foo").slice(pl.len() - 10, pl.col("bar"))
        >>> e_sum_slice.meta.output_name()
        'foo'
        >>> pl.len().meta.output_name()
        'len'
        N)r   Úmeta_output_namer   rG   s     r   rH   zExprMetaNameSpace.output_nameÂ   s2   € ð2	Ø—<‘<×0Ñ0Ó2Ð2øÜò 	Ù(ÙØð	ús   ‚ œ+©+N)Úschemac               óp   — | j                   j                  |«      D �cg c]  }t        |«      ‘Œ c}S c c}w )a<  
        Pop the latest expression and return the input(s) of the popped expression.

        Returns
        -------
        list of Expr
            A list of expressions which in most cases will have a unit length.
            This is not the case when an expression has multiple inputs.
            For instance in a `fold` expression.

        Examples
        --------
        >>> e = pl.col("foo") + pl.col("bar")
        >>> first = e.meta.pop()[0]
        >>> first.meta == pl.col("bar")
        True
        >>> first.meta == pl.col("foo")
        False
        )r   Úmeta_popr
   )r   rL   Úes      r   ÚpopzExprMetaNameSpace.popâ   s+   € ð( '+§l¡l×&;Ñ&;¸FÓ&CÖD ”	˜!•ÒDÐDùÒDs   ž3c                ó6   — | j                   j                  «       S )aD  
        Get a list with the root column name.

        Examples
        --------
        >>> e = pl.col("foo") * pl.col("bar")
        >>> e.meta.root_names()
        ['foo', 'bar']
        >>> e_filter = pl.col("foo").filter(pl.col("bar") == 13)
        >>> e_filter.meta.root_names()
        ['foo', 'bar']
        >>> e_sum_over = pl.sum("foo").over("groups")
        >>> e_sum_over.meta.root_names()
        ['foo', 'groups']
        >>> e_sum_slice = pl.sum("foo").slice(pl.len() - 10, pl.col("bar"))
        >>> e_sum_slice.meta.root_names()
        ['foo', 'bar']
        )r   Úmeta_root_namesr"   s    r   Ú
root_nameszExprMetaNameSpace.root_namesø   s   € ð& �|‰|×+Ñ+Ó-Ð-r   c                óH   — t        | j                  j                  «       «      S )aR  
        Undo any renaming operation like `alias` or `name.keep`.

        Examples
        --------
        >>> e = pl.col("foo").alias("bar")
        >>> e.meta.undo_aliases().meta == pl.col("foo")
        True
        >>> e = pl.col("foo").sum().over("bar")
        >>> e.name.keep().meta.undo_aliases().meta == e
        True
        )r
   r   Úmeta_undo_aliasesr"   s    r   Úundo_aliaseszExprMetaNameSpace.undo_aliases  s   € ô ˜Ÿ™×7Ñ7Ó9Ó:Ð:r   c                ó,   — t        | j                  «      S )zReturn the original expression.)r
   r   r"   s    r   Úas_expressionzExprMetaNameSpace.as_expression  s   € ä˜Ÿ™Ó&Ð&r   c                óp   — t         j                  j                  | j                  j	                  «       «      S )a2  
        Try to turn this expression in a selector.

        Raises if the underlying expressions is not a column or selector.

        .. warning::
            This functionality is considered **unstable**. It may be changed
            at any point without it being considered a breaking change.
        )ÚplÚSelectorÚ_from_pyselectorr   Úinto_selectorr"   s    r   Úas_selectorzExprMetaNameSpace.as_selector   s&   € ô �{‰{×+Ñ+¨D¯L©L×,FÑ,FÓ,HÓIÐIr   .©Úformatc                ó   — y r   r.   ©r   Úfiler`   s      r   Ú	serializezExprMetaNameSpace.serialize,  s   € ð r   c                ó   — y r   r.   rb   s      r   rd   zExprMetaNameSpace.serialize1  s   € ØNQr   c                ó   — y r   r.   rb   s      r   rd   zExprMetaNameSpace.serialize4  s   € ð r   Úbinaryc               ó¬   — |dk(  r| j                   j                  }n,|dk(  r| j                   j                  }nd|›�}t        |«      ‚t	        |||«      S )u§  
        Serialize this expression to a file or string in JSON format.

        Parameters
        ----------
        file
            File path to which the result should be written. If set to `None`
            (default), the output is returned as a string instead.
        format
            The format in which to serialize. Options:

            - `"binary"`: Serialize to binary format (bytes). This is the default.
            - `"json"`: Serialize to JSON format (string).

        See Also
        --------
        Expr.deserialize

        Notes
        -----
        Serialization is not stable across Polars versions: a LazyFrame serialized
        in one Polars version may not be deserializable in another Polars version.

        Examples
        --------
        Serialize the expression into a binary representation.

        >>> expr = pl.col("foo").sum().over("bar")
        >>> bytes = expr.meta.serialize()
        >>> type(bytes)
        <class 'bytes'>

        The bytes can later be deserialized back into an `Expr` object.

        >>> import io
        >>> pl.Expr.deserialize(io.BytesIO(bytes))
        <Expr ['col("foo").sum().over([col("baâ€¦'] at ...>
        rg   Újsonz0`format` must be one of {'binary', 'json'}, got )r   Úserialize_binaryÚserialize_jsonÚ
ValueErrorr   )r   rc   r`   Ú
serializerÚmsgs        r   rd   zExprMetaNameSpace.serialize9  sX   € ðX �XÒØŸ™×6Ñ6‰JØ�vÒØŸ™×4Ñ4‰JàFÀvÀjÐQˆCÜ˜S“/Ð!ä& z°4¸Ó@Ð@r   c                 ó   — y r   r.   ©r   rc   s     r   Ú
write_jsonzExprMetaNameSpace.write_jsono  s   € Ø36r   c                 ó   — y r   r.   rp   s     r   rq   zExprMetaNameSpace.write_jsonr  s   € Ø=@r   z;`meta.write_json` was renamed; use `meta.serialize` insteadc                ó(   — | j                  |d¬«      S )z‹
        Write expression to json.

        .. deprecated:: 0.20.11
            This method has been renamed to :meth:`serialize`.
        ri   r_   )rd   rp   s     r   rq   zExprMetaNameSpace.write_jsonu  s   € ð �~‰~˜d¨6ˆ~Ó2Ð2r   )Úreturn_as_stringrL   c                ó   — y r   r.   ©r   rt   rL   s      r   Útree_formatzExprMetaNameSpace.tree_format  s   € ð r   c                ó   — y r   r.   rv   s      r   rw   zExprMetaNameSpace.tree_format‡  s   € ð r   c               óX   — | j                   j                  |«      }|r|S t        |«       y)am  
        Format the expression as a tree.

        Parameters
        ----------
        return_as_string:
            If True, return as string rather than printing to stdout.
        schema
            Optionally provide a schema for the expression tree formatter.
            This is a mapping of column names to their data types. If provided,
            it may be used to enhance the tree formatting with type information.

        Examples
        --------
        >>> e = (pl.col("foo") * pl.col("bar")).sum().over(pl.col("ham")) / 2
        >>> e.meta.tree_format(return_as_string=True)  # doctest: +SKIP
        N)r   Úmeta_tree_formatÚprint)r   rt   rL   Úss       r   rw   zExprMetaNameSpace.tree_formatŒ  s*   € ð( �L‰L×)Ñ)¨&Ó1ˆÙØˆHä�!ŒHØr   )g      0@g      (@)ÚshowÚoutput_pathÚ
raw_outputÚfigsizerL   c               óX   — | j                   j                  |«      }t        |||||¬«      S )a¿  
        Format the expression as a Graphviz graph.

        Note that Graphviz must be installed to render the visualization (if not
        already present, you can download it here: `<https://graphviz.org/download>`_).

        Parameters
        ----------
        show
            Show the figure.
        output_path
            Write the figure to disk.
        raw_output
            Return dot syntax. This cannot be combined with `show` and/or `output_path`.
        figsize
            Passed to matplotlib if `show == True`.
        schema
            Optionally provide a schema for the expression tree formatter.
            This is a mapping of column names to their data types. If provided,
            it may be used to enhance the tree formatting with type information.

        Examples
        --------
        >>> e = (pl.col("foo") * pl.col("bar")).sum().over(pl.col("ham")) / 2
        >>> e.meta.show_graph()  # doctest: +SKIP
        )Údotr}   r~   r   r€   )r   Úmeta_show_graphr	   )r   r}   r~   r   r€   rL   r‚   s          r   Ú
show_graphzExprMetaNameSpace.show_graph§  s5   € ðF �l‰l×*Ñ*¨6Ó2ˆÜ ØØØ#Ø!Øô
ð 	
r   c                ó^   — t        | j                  j                  |j                  «      «      S r   )r
   r   Úmeta_replace_elementr   s     r   Ú_replace_elementz"ExprMetaNameSpace._replace_elementÓ  s    € Ü˜Ÿ™×:Ñ:¸4¿<¹<ÓHÓIÐIr   )r   r   ÚreturnÚNone)rˆ   Ústr)rˆ   Úint)r+   zExprMetaNameSpace | Exprrˆ   Úbool)rˆ   rŒ   )r=   rŒ   rˆ   rŒ   )rE   úLiteral[True]rˆ   rŠ   )rE   úLiteral[False]rˆ   ú
str | None)rE   rŒ   rˆ   r�   )rL   zSchemaDict | Nonerˆ   z
list[Expr])rˆ   z	list[str])rˆ   r   )rˆ   zpl.Selector).)rc   r‰   r`   zLiteral['binary']rˆ   Úbytes)rc   r‰   r`   zLiteral['json']rˆ   rŠ   )rc   úIOBase | str | Pathr`   r   rˆ   r‰   r   )rc   úIOBase | str | Path | Noner`   r   rˆ   zbytes | str | None)rc   r‰   rˆ   rŠ   )rc   r‘   rˆ   r‰   )rc   r’   rˆ   r�   )rt   rŽ   rL   úNone | SchemaDictrˆ   r‰   )rt   r�   rL   r“   rˆ   rŠ   )rt   rŒ   rL   r“   rˆ   r�   )r}   rŒ   r~   zstr | Path | Noner   rŒ   r€   ztuple[float, float]rL   r“   rˆ   r�   )r   r   rˆ   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	_accessorr   r!   r$   r&   r,   r/   r1   r3   r6   r9   r<   rA   rD   r   rH   rP   rS   rV   rX   r^   rd   rq   r   rw   r„   r‡   r.   r   r   r   r      si  „ Ù4à€Ió$ó;ó<ó'ó3ó!ó3ó "ó 
8ó-ó$
7ð =Bõ $EðL 49õ <ð6 ØDHÔUó ØUàÚVó ØVà;?õ ð@ 26õ Eó,.ó*;ó'ó
Jð àðØ?BñØðØ+<ðà	òó ðð ÛQó ØQààJMñØ'ðØ4Gðà	òó ðð ,0ð4Að '/ñ	4Aà(ð4Að $ð	4Að
 
ó4Aðl Û6ó Ø6àÚ@ó Ø@áÐMÓNó3ó Oð3ð ð ,/Ø$(ñ	ð )ðð "ð	ð
 
òó ðð àNRñØ#0ðØ:Kðà	òó ðð
 +0ÈTñØ#'ðØ9Jðà	óð< Ø)-Ø Ø'3Ø$(ñ*
ð ð*
ð 'ð	*
ð
 ð*
ð %ð*
ð "ð*
ð 
ó*
ôXJr   r   )!Ú
__future__r   Útypingr   r   r   Úpolars._reexportÚ	_reexportrZ   Úpolars._utils.deprecationr   Úpolars._utils.serder   Úpolars._utils.variousr	   Úpolars._utils.wrapr
   Úpolars.exceptionsr   ÚsysÚior   Úpathlibr   Úpolarsr   Úpolars._typingr   r   Úversion_infoÚwarningsÚtyping_extensionsr   r.   r   r   ú<module>rª      sT   ðÝ "ç 3Ñ 3å Ý 0Ý 7Ý 3Ý (Ý *áÛÝÝåß>à
×Ñ˜7Ò"Þ'å0÷zJò zJr   