
    'h7                       S SK Jr  S SKJrJrJr  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  S SKJr  \(       a;  S SKrS S	KJr  S S
KJr  S SKJr  S SKJrJr  \R:                  S:  a  S SKJ
r
  OS SKJ
r
   " S S5      r g)    )annotations)TYPE_CHECKINGLiteraloverloadN)
deprecated)serialize_polars_object)display_dot_graph)	wrap_expr)ComputeError)IOBase)Path)Expr)
SchemaDictSerializationFormat)      c                  z   \ rS rS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
S0S	 jrS0S
 jrS0S jrSS.S1S jjrSS.S1S jjr\SS.S2S jj5       r\S3S j5       rSS.S4S jjrSS.S5S jjrS6S jrS7S jrS8S jr\ S9SS.     S:S jjj5       r\S9S;S jj5       r\SS.     S<S jj5       r S=S S.     S>S! jjjr\S9S?S" jj5       r\S@S# j5       r\" S$5      S=SAS% jj5       r\SSS&.     SBS' jj5       r\SS.     SCS( jj5       rSSS&.     SDS) jjrSSSS*SS+.           SES, jjrS-rg)FExprMetaNameSpace   z*Namespace for expressions on a meta level.metac                &    UR                   U l         g N_pyexpr)selfexprs     cC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\polars/expr/meta.py__init__ExprMetaNameSpace.__init__   s    ||    c                L    U R                   R                  UR                   5      $ r   r   meta_eqr   others     r   __eq__ExprMetaNameSpace.__eq__"   s    ||##EMM22r    c                    X:X  + $ r    r$   s     r   __ne__ExprMetaNameSpace.__ne__%   s      r    c                L    U R                   R                  UR                   5      $ )a   
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   eqExprMetaNameSpace.eq(   s     ||##EMM22r    c                .    U R                  U5      (       + $ )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
)r-   r$   s     r   neExprMetaNameSpace.ne8   s     775>!!r    c                6    U R                   R                  5       $ )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_outputsr   s    r   has_multiple_outputs&ExprMetaNameSpace.has_multiple_outputsH   s     ||5577r    c                6    U R                   R                  5       $ )a	  
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_columnr4   s    r   	is_columnExprMetaNameSpace.is_columnT   s      ||**,,r    c                6    U R                   R                  5       $ )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_projectionr4   s    r   is_regex_projection%ExprMetaNameSpace.is_regex_projectionf   s     ||4466r    F)allow_aliasingc               8    U R                   R                  U5      $ )a  
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_selection%ExprMetaNameSpace.is_column_selectionr   s    H ||44^DDr    c               8    U R                   R                  U5      $ )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_literalrB   s     r   
is_literalExprMetaNameSpace.is_literal   s    2 ||++N;;r    T)raise_if_undeterminedc                   g r   r)   r   rI   s     r   output_nameExprMetaNameSpace.output_name   s    RUr    c                   g r   r)   rK   s     r   rL   rM      s    SVr    c               h     U R                   R                  5       $ ! [         a    U(       d   ge f = f)a  
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   rK   s     r   rL   rM      s2    2	<<0022 	(	s    11N)schemac               v    U R                   R                  U5       Vs/ s H  n[        U5      PM     sn$ s  snf )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   rQ   es      r   popExprMetaNameSpace.pop   s1    ( '+ll&;&;F&CD&C	!&CDDDs   6c                6    U R                   R                  5       $ )a  
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_namesr4   s    r   
root_namesExprMetaNameSpace.root_names   s    & ||++--r    c                H    [        U R                  R                  5       5      $ )a  
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_aliasesr4   s    r   undo_aliasesExprMetaNameSpace.undo_aliases  s     779::r    c                p    [         R                  R                  U R                  R	                  5       5      $ )a  
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_selectorr4   s    r   as_selectorExprMetaNameSpace.as_selector  s&     {{++DLL,F,F,HIIr    .formatc                   g r   r)   r   filerg   s      r   	serializeExprMetaNameSpace.serialize  s     r    c                   g r   r)   ri   s      r   rk   rl   $  s    NQr    c                   g r   r)   ri   s      r   rk   rl   '  s     r    binaryc                   US:X  a  U R                   R                  nO.US:X  a  U R                   R                  nOSU< 3n[        U5      e[	        X1U5      $ )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 ...>
ro   jsonz0`format` must be one of {'binary', 'json'}, got )r   serialize_binaryserialize_json
ValueErrorr   )r   rj   rg   
serializermsgs        r   rk   rl   ,  sV    X X66Jv44JFvjQCS/!&z@@r    c                    g r   r)   r   rj   s     r   
write_jsonExprMetaNameSpace.write_jsonb  s    36r    c                    g r   r)   rx   s     r   ry   rz   e  s    =@r    z;`meta.write_json` was renamed; use `meta.serialize` insteadc                "    U R                  USS9$ )zk
Write expression to json.

.. deprecated:: 0.20.11
    This method has been renamed to :meth:`serialize`.
rq   rf   )rk   rx   s     r   ry   rz   h  s     ~~d6~22r    )return_as_stringrQ   c                   g r   r)   r   r}   rQ   s      r   tree_formatExprMetaNameSpace.tree_formatr  s     r    c                   g r   r)   r   s      r   r   r   z  s     r    c               b    U R                   R                  U5      nU(       a  U$ [        U5        g)a"  
Format the expression as a tree.

Parameters
----------
return_as_string:
    If True, return as string rather than printing to stdout.

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   r}   rQ   ss       r   r   r     s*      LL))&1H!Hr    )g      0@g      (@)showoutput_path
raw_outputfigsizerQ   c               R    U R                   R                  U5      n[        UUUUUS9$ )a4  
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`.

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   rQ   r   s          r   
show_graphExprMetaNameSpace.show_graph  s4    > ll**62 #!
 	
r    r   )r   r   returnNone)r%   zExprMetaNameSpace | Exprr   bool)r   r   )r?   r   r   r   )rI   Literal[True]r   str)rI   Literal[False]r   
str | None)rI   r   r   r   )rQ   zSchemaDict | Noner   z
list[Expr])r   z	list[str])r   r   )r   zpl.Selector).)rj   r   rg   zLiteral['binary']r   bytes)rj   r   rg   zLiteral['json']r   r   )rj   IOBase | str | Pathrg   r   r   r   r   )rj   IOBase | str | Path | Nonerg   r   r   zbytes | str | None)rj   r   r   r   )rj   r   r   r   )rj   r   r   r   )r}   r   rQ   None | SchemaDictr   r   )r}   r   rQ   r   r   r   )r}   r   rQ   r   r   r   )r   r   r   zstr | Path | Noner   r   r   ztuple[float, float]rQ   r   r   r   )__name__
__module____qualname____firstlineno____doc__	_accessorr   r&   r*   r-   r0   r5   r9   r=   rC   rG   r   rL   rU   rY   r]   rd   rk   ry   r   r   r   __static_attributes__r)   r    r   r   r      sS   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	 
 +0T#'9J	4 )- '3$(&
 &
 '	&

 &
 %&
 "&
 
&
 &
r    r   )!
__future__r   typingr   r   r   polars._reexport	_reexportr`   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      sR    " 3 3  0 7 3 ( *>
7"'0b
 b
r    