
    ha                       S SK Jr  S SKrS SKJr  S SKJr  S SKJ	r	J
r
JrJrJrJr  S SKJrJr  S SKJrJrJrJr  S SKJrJrJr  S S	KJrJrJrJrJ r J!r!J"r"J#r#J$r$J%r%J&r&J'r'J(r(  \	(       a$  S S
K)J*r*J+r+  S SK,J-r-  S SK.J/r/J0r0J1r1J2r2J3r3J4r4J5r5J6r6J7r7  \" S5      r8\9\:\;\<\=\>\4r?\R                  \R                  \R                  4rC\SS.     S9S jj5       rD\SS.     S:S jj5       rD\SS.     S;S jj5       rD\S<S j5       rDSS.     S=S jjrD\S>S j5       rE\S?S j5       rE\S@S j5       rE\SS.           SAS jj5       rE\SSSS.           SBS jj5       rE\SSSS.           SCS jj5       rE\SSS.           SDS jj5       rE\SSS.           SES  jj5       rE\SSS!.           SFS" jj5       rE\SSS#.           SGS$ jj5       rE\SSSSS%.           SHS& jj5       rE\SSSSS%.           SIS' jj5       rE\SSSS(.           SJS) jj5       rE\SSSS*.           SKS+ jj5       rE\SSSS,.           SLS- jj5       rE\            SMS. j5       rESSSSS%.             SNS/ jjrESSSSSS0.               SOS1 jjrF    SPS2 jrG    SPS3 jrH SQS4SSS4S%.           SRS5 jjjrISSS6 jrJSTS7 jrK/ S8QrLg)U    )annotationsN)Decimalwraps)TYPE_CHECKINGAnyCallableLiteralTypeVaroverload)EPOCHMS_PER_SECOND)is_native_arrowis_native_pandas_likeis_native_polarsis_native_spark_like)ImplementationVersionhas_native_namespace)get_dask_expr	get_numpy
get_pandasis_cupy_scalaris_dask_dataframeis_duckdb_relationis_ibis_tableis_numpy_scalaris_pandas_like_dataframeis_polars_lazyframeis_polars_seriesis_pyarrow_scalaris_pyarrow_table	DataFrame	LazyFrameSeries)	
DataFrameTIntoDataFrameT	IntoFrame
IntoFrameTIntoLazyFrameT
IntoSeriesIntoSeriesT
LazyFrameTSeriesTT.pass_throughc                   g N narwhals_objectr3   s     eC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\narwhals/translate.py	to_nativer:   5   s         c                   g r5   r6   r7   s     r9   r:   r:   9   s     r;   c                   g r5   r6   r7   s     r9   r:   r:   =   s     r;   c                   g r5   r6   r7   s     r9   r:   r:   A   s    CFr;   Fc                   SSK Jn  SSKJn  [	        X5      (       a  U R
                  R                  $ [	        X5      (       a  U R                  R                  $ U(       d  S[        U 5       S3n[        U5      eU $ )a=  Convert Narwhals object to native one.

Arguments:
    narwhals_object: Narwhals object.
    pass_through: Determine what happens if `narwhals_object` isn't a Narwhals class

        - `False` (default): raise an error
        - `True`: pass object through as-is

Returns:
    Object of class that user started with.
r   )	BaseFramer&   zExpected Narwhals object, got .)narwhals.dataframer@   narwhals.seriesr'   
isinstance_compliant_frame_native_frame_compliant_seriesnativetype	TypeError)r8   r3   r@   r'   msgs        r9   r:   r:   E   sk    & -&/--//===/**00777.tO/D.EQGnr;   c                    g r5   r6   native_objectkwdss     r9   from_nativerP   f   s    ADr;   c                    g r5   r6   rM   s     r9   rP   rP   j       GJr;   c                    g r5   r6   rM   s     r9   rP   rP   n   rR   r;   )series_onlyc                   g r5   r6   rN   r3   
eager_onlyrT   allow_seriess        r9   rP   rP   r   s     7:r;   )rW   rT   rX   c                   g r5   r6   rV   s        r9   rP   rP   }        !$r;   c                   g r5   r6   rV   s        r9   rP   rP           	r;   )rT   rX   c                   g r5   r6   rV   s        r9   rP   rP      rZ   r;   c                   g r5   r6   rV   s        r9   rP   rP      r\   r;   )rW   rT   c                   g r5   r6   rV   s        r9   rP   rP      s	     ORr;   )rW   rX   c                   g r5   r6   rV   s        r9   rP   rP           r;   r3   rW   rT   rX   c                   g r5   r6   rV   s        r9   rP   rP      rZ   r;   c                   g r5   r6   rV   s        r9   rP   rP      rZ   r;   )r3   rT   rX   c                   g r5   r6   rV   s        r9   rP   rP      rZ   r;   )r3   rW   rT   c                   g r5   r6   rV   s        r9   rP   rP      s     58r;   )r3   rW   rX   c                   g r5   r6   rV   s        r9   rP   rP      ra   r;   c                   g r5   r6   rV   s        r9   rP   rP      s     r;   c          
         U(       a#  S[        [        U5      5      < 3n[        U5      e[        U UUSUU[        R
                  S9$ )a5  Convert `native_object` to Narwhals Dataframe, Lazyframe, or Series.

Arguments:
    native_object: Raw object from user.
        Depending on the other arguments, input object can be

        - a Dataframe / Lazyframe / Series supported by Narwhals (pandas, Polars, PyArrow, ...)
        - an object which implements `__narwhals_dataframe__`, `__narwhals_lazyframe__`,
          or `__narwhals_series__`
    pass_through: Determine what happens if the object can't be converted to Narwhals

        - `False` (default): raise an error
        - `True`: pass object through as-is
    eager_only: Whether to only allow eager objects

        - `False` (default): don't require `native_object` to be eager
        - `True`: only convert to Narwhals if `native_object` is eager
    series_only: Whether to only allow Series

        - `False` (default): don't require `native_object` to be a Series
        - `True`: only convert to Narwhals if `native_object` is a Series
    allow_series: Whether to allow Series (default is only Dataframe / Lazyframe)

        - `False` or `None` (default): don't convert to Narwhals if `native_object` is a Series
        - `True`: allow `native_object` to be a Series

Returns:
    DataFrame, LazyFrame, Series, or original object, depending
        on which combination of parameters was passed.
z1from_native() got an unexpected keyword argument F)r3   rW   eager_or_interchange_onlyrT   rX   version)nextiterrJ   _from_native_implr   MAIN)rN   r3   rW   rT   rX   rO   rK   s          r9   rP   rP     sN    N A$tDzBRAUVn!"'! r;   )r3   rW   rj   rT   rX   c                  SSK JnJnJn	Jn
  SSKJnJn  SSKJ	n  [        XU45      (       a	  U(       d  U $ [        X5      (       a  U(       d  U(       a  U $ U(       a  USL a  Sn[        U5      eSnU(       a  U(       a  Sn[        U5      eU" U 5      (       aJ  U(       a  U(       d  S	n[        U5      eU $ UR                  U R                  5       R                  U5      S
S9$ U	" U 5      (       an  U(       a  U(       d  Sn[        U5      eU $ U(       d  U(       a  U(       d  Sn[        U5      eU $ UR!                  U R#                  5       R                  U5      S
S9$ U
" U 5      (       aJ  U(       d  U(       d  Sn[        U5      eU $ UR%                  U R'                  5       R                  U5      S
S9$ [)        U 5      (       a  U(       a<  [+        U 5      (       d,  U(       d#  S[-        U 5      R.                   3n[        U5      eU $ U(       d  U(       a&  [1        U 5      (       a  U(       d  Sn[        U5      eU $ U(       d&  [+        U 5      (       a  U(       d  Sn[        U5      eU $ UR2                  R5                  U 5      R6                  R9                  U 5      R;                  5       $ [=        U 5      (       a  [?        U 5      (       a4  U(       a,  U(       d#  S[-        U 5      R.                   3n[        U5      eU $ OU(       d  U(       d  Sn[        U5      eU $ UR2                  R5                  U 5      R6                  R9                  U 5      R;                  5       $ [A        U 5      (       a  [C        U 5      (       a4  U(       a,  U(       d#  S[-        U 5      R.                   3n[        U5      eU $ OU(       d  U(       d  Sn[        U5      eU $ UR2                  R5                  U 5      R6                  R9                  U 5      R;                  5       $ [E        U 5      (       a  U(       a  U(       d  Sn[        U5      eU $ U(       d  U(       a  U(       d  Sn[        U5      eU $ [F        RH                  RK                  5       S::  a  [M        5       c  Sn[O        U5      eUR2                  RQ                  [F        RH                  5      R6                  R9                  U 5      R;                  5       $ [S        U 5      (       af  U(       d  U(       a  U(       d  Sn[        U5      eU $ UR2                  R5                  U 5      R6                  R9                  U 5      R;                  5       $ [U        U 5      (       af  U(       d  U(       a  U(       d  Sn[        U5      eU $ UR2                  R5                  U 5      R6                  R9                  U 5      R;                  5       $ [W        U 5      (       a}  UR2                  R5                  U 5      nU(       d  U(       d  U(       a$  U(       d  SURX                   S3n[        U5      eU $ UR6                  R9                  U 5      R;                  5       $ U" U 5      (       aw  SSK-J.n  U(       d  U(       a  U(       d  Sn[        U5      eU $ U[^        R`                  La  U(       a  U $ Sn[        U5      e[^        R`                  R                  U" U 5      SS9$ U(       d  S[-        U 5       3n[        U5      eU $ )Nr   )_supports_dataframe_interchangeis_compliant_dataframeis_compliant_lazyframeis_compliant_seriesr#   r&   FzJInvalid parameter combination: `series_only=True` and `allow_series=False`TzUInvalid parameter combination: `eager_only=True` and `eager_or_interchange_only=True`z,Cannot only use `series_only` with dataframefull)levelz,Cannot only use `series_only` with lazyframezJCannot only use `eager_only` or `eager_or_interchange_only` with lazyframez4Please set `allow_series=True` or `series_only=True`z#Cannot only use `series_only` with zQCannot only use `eager_only` or `eager_or_interchange_only` with polars.LazyFramez1Cannot only use `series_only` with dask DataFramezOCannot only use `eager_only` or `eager_or_interchange_only` with dask DataFrame)i        zPlease install dask-exprzNCannot only use `series_only=True` or `eager_only=False` with DuckDBPyRelationzHCannot only use `series_only=True` or `eager_only=False` with ibis.TablezPCannot only use `series_only`, `eager_only` or `eager_or_interchange_only` with z
 DataFrame)InterchangeFramezhCannot only use `series_only=True` or `eager_only=False` with object which only implements __dataframe__a+  The Dataframe Interchange Protocol is no longer supported in the main `narwhals` namespace.

You may want to:
 - Use `narwhals.stable.v1`, where it is still supported.
    - See https://narwhals-dev.github.io/narwhals/backcompat
 - Use `pass_through=True` to pass the object through without raising.interchangezLExpected pandas-like dataframe, Polars dataframe, or Polars lazyframe, got: )1narwhals._utilsrq   rr   rs   rt   rB   r$   r%   rC   r'   rD   
ValueErrorrJ   	dataframe__narwhals_dataframe___with_version	lazyframe__narwhals_lazyframe__series__narwhals_series__r   r    rI   __qualname__r   	namespacefrom_native_object	compliantrP   to_narwhalsr   r   r   r"   r   r   DASK_backend_versionr   ImportErrorfrom_backendr   r   r   implementationnarwhals._interchange.dataframery   r   V1)rN   r3   rW   rj   rT   rX   rk   rq   rr   rs   rt   r$   r%   r'   rK   ns_sparkry   s                    r9   rn   rn   ;  s     8& -Y!788-((k\5 ^CS/!/eo m,,Dn$    002@@IQW ! 
 	
 
 	.	.Dn$  2bn$    002@@IQW ! 
 	
 
]	+	+Ln$  ~~--/==gFf  
 	

 
-	(	(/>>;D<O<\<\;]^n$  39L:
 :
  in$  "2="A"ALn$  00?Y{{=1[]	
 
}	-	-#M22#?]@S@`@`?abC#C.($$	 
 Ln$  00?Y{{=1[]	
 
	'	'M**#?]@S@`@`?abC#C.($$	 
 Ln$  00?Y{{=1[]	
 
=	)	)In$  2gn$  002mC',Cc""**>+>+>?Y{{=1[]	
 
M	*	*fn$  00?Y{{=1[]	
 
}	%	%`n$  00?Y{{=1[]	
 
m	,	,$$77F*(A$334J@   n$  !!--m<HHJJ 
)	7	7DF   n$  '**$$$Y  C. zz##$4]$C=#YY\]abo]p\qrnr;   c                     U (       d  Sn[        U5      eU  Vs1 s H  n[        U5      iM     nn[        U5      S:w  a  SU S3n[        U5      eUR                  5       $ s  snf )a[  Get native namespace from object.

Arguments:
    obj: Dataframe, Lazyframe, or Series. Multiple objects can be
        passed positionally, in which case they must all have the
        same native namespace (else an error is raised).

Returns:
    Native module.

Examples:
    >>> import polars as pl
    >>> import pandas as pd
    >>> import narwhals as nw
    >>> df = nw.from_native(pd.DataFrame({"a": [1, 2, 3]}))
    >>> nw.get_native_namespace(df)
    <module 'pandas'...>
    >>> df = nw.from_native(pl.DataFrame({"a": [1, 2, 3]}))
    >>> nw.get_native_namespace(df)
    <module 'polars'...>
z=At least one object must be passed to `get_native_namespace`.rx   z0Found objects with different native namespaces: rA   )r|    _get_native_namespace_single_objlenpop)objrK   xresults       r9   get_native_namespacer     sf    0 Mo;>?3a.q13F?
6{a@Jo::<	 @s   A c                    [        U 5      (       a  U R                  5       $ [        R                  R                  R                  U 5      R                  R                  5       $ r5   )r   __native_namespace__r   ro   r   r   r   to_native_namespace)r   s    r9   r   r   ?  sL     C  ''))<<!!44n((*+r;   Tc               :   ^^^^ SUUUU4S jjnU c  U$ U" U 5      $ )a,  Decorate function so it becomes dataframe-agnostic.

This will try to convert any dataframe/series-like object into the Narwhals
respective DataFrame/Series, while leaving the other parameters as they are.
Similarly, if the output of the function is a Narwhals DataFrame or Series, it will be
converted back to the original dataframe/series type, while if the output is another
type it will be left as is.
By setting `pass_through=False`, then every input and every output will be required to be a
dataframe/series-like object.

Arguments:
    func: Function to wrap in a `from_native`-`to_native` block.
    pass_through: Determine what happens if the object can't be converted to Narwhals

        - `False`: raise an error
        - `True` (default): pass object through as-is
    eager_only: Whether to only allow eager objects

        - `False` (default): don't require `native_object` to be eager
        - `True`: only convert to Narwhals if `native_object` is eager
    series_only: Whether to only allow Series

        - `False` (default): don't require `native_object` to be a Series
        - `True`: only convert to Narwhals if `native_object` is a Series
    allow_series: Whether to allow Series (default is only Dataframe / Lazyframe)

        - `False` or `None`: don't convert to Narwhals if `native_object` is a Series
        - `True` (default): allow `native_object` to be a Series

Returns:
    Decorated function.

Examples:
    Instead of writing

    >>> import narwhals as nw
    >>> def agnostic_group_by_sum(df):
    ...     df = nw.from_native(df, pass_through=True)
    ...     df = df.group_by("a").agg(nw.col("b").sum())
    ...     return nw.to_native(df)

    you can just write

    >>> @nw.narwhalify
    ... def agnostic_group_by_sum(df):
    ...     return df.group_by("a").agg(nw.col("b").sum())
c                >   >^  [        T 5      SUUU UU4S jj5       nU$ )Nc                   > U  Vs/ s H  n[        UTTTT
S9PM     n nUR                  5        VVs0 s H  u  p4U[        UTTTT
S9_M     nnn/ U QUR                  5       Q7 Vs1 s H   n[        USS 5      =n(       d  M  U" 5       iM"     nn[	        U5      S:  a  Sn[        U5      eT" U 0 UD6n	[        U	TS9$ s  snf s  snnf s  snf )Nrb   r   rx   z_Found multiple backends. Make sure that all dataframe/series inputs come from the same backend.r2   )rP   itemsvaluesgetattrr   r|   r:   )argskwargsargnamevaluevbbackendsrK   r   rX   rW   funcr3   rT   s             r9   wrapper.narwhalify.<locals>.decorator.<locals>.wrapper  s     	  C !-) +!-    	& $*<<>	 $2KD k!-) +!-  $2  	 342&--/22A $:DAAAA 2   8}q w o%4*6*FV,??E		s   B=C&CC)r   r   r   r   returnr   r   )r   r   rX   rW   r3   rT   s   ` r9   	decoratornarwhalify.<locals>.decorator  s)    	t#	@ #	@ 
#	@J r;   )r   Callable[..., Any]r   r   r6   )r   r3   rW   rT   rX   r   s    ```` r9   
narwhalifyr   I  s(    p' 'R | r;   c                4   [        5       nU b  [        U [        5      (       a  U nU$ [        5       =n(       a^  [        XR                  5      (       aD  U R
                  S:X  a4  U R                  5       [        -  n[        [        R                  " US9-   nU$ [        U 5      (       d  [        U 5      (       a  U R                  5       nU$ U(       a,  [        XR                  5      (       a  U R                  5       nU$ U(       a,  [        XR                  5      (       a  U R!                  5       nU$ [        U ["        5      (       a  U nU$ [%        U 5      (       a  SnU$ ['        U 5      (       a  U R)                  5       nU$ S[+        U 5       SU < 3n[-        U5      e)a)  If a scalar is not Python native, converts it to Python native.

Arguments:
    scalar_like: Scalar-like value.

Returns:
    Python scalar.

Raises:
    ValueError: If the object is not convertible to a scalar.

Examples:
    >>> import narwhals as nw
    >>> import pandas as pd
    >>> df = nw.from_native(pd.DataFrame({"a": [1, 2, 3]}))
    >>> nw.to_py_scalar(df["a"].item(0))
    1
    >>> import pyarrow as pa
    >>> df = nw.from_native(pa.table({"a": [1, 2, 3]}))
    >>> nw.to_py_scalar(df["a"].item(0))
    1
    >>> nw.to_py_scalar(1)
    1
Nzdatetime64[ns])microsecondsz/Expected object convertible to a scalar, found z.
)r   rD   NON_TEMPORAL_SCALAR_TYPESr   
datetime64dtypeitemr   r   dt	timedeltar   r   	Timestampto_pydatetime	Timedeltato_pytimedeltaTEMPORAL_SCALAR_TYPES_is_pandas_nar!   as_pyrI   r|   )scalar_likepdscalarnpmsrK   s         r9   to_py_scalarr     s   4 
Bj6OPP8 M5 {		{MM22!11=0266* M) 
	%	%)D)D!!#& M% 

;55**," M! 

;55++- M 
K!6	7	7 M 
{	#	# M 
;	'	'""$ M	 >d;>O=PPSo 	 or;   c                    [        [        5       =n=(       a=    UR                  R                  R	                  U 5      =(       a    UR                  U 5      5      $ r5   )boolr   apitypes	is_scalarisna)r   r   s     r9   r   r     s:    z|#U)?)?)DUQTVVr;   )r   r   r:   r   )r8   DataFrame[IntoDataFrameT]r3   Literal[False]r   r)   )r8   zLazyFrame[IntoFrameT]r3   r   r   r+   )r8   Series[IntoSeriesT]r3   r   r   r.   )r8   r   r3   r   r   r   )r8   zGDataFrame[IntoDataFrameT] | LazyFrame[IntoFrameT] | Series[IntoSeriesT]r3   r   r   z/IntoDataFrameT | IntoFrameT | IntoSeriesT | Any)rN   r0   rO   r   r   r0   )rN   r(   rO   r   r   r(   )rN   r/   rO   r   r   r/   )rN   zIntoDataFrameT | IntoSeriesTr3   Literal[True]rW   r   rT   r   rX   r   r   z/DataFrame[IntoDataFrameT] | Series[IntoSeriesT])rN   r)   r3   r   rW   r   rT   r   rX   Noner   r   )rN   r1   r3   r   rW   r   rT   r   rX   r   r   r1   )rN   r)   r3   r   rW   r   rT   r   rX   r   r   r   )rN   r1   r3   r   rW   r   rT   r   rX   r   r   r1   )rN   z)IntoFrameT | IntoLazyFrameT | IntoSeriesTr3   r   rW   r   rT   r   rX   r   r   zGDataFrame[IntoFrameT] | LazyFrame[IntoLazyFrameT] | Series[IntoSeriesT])rN   r.   r3   r   rW   r   rT   r   rX   r   r   r   )rN   r,   r3   r   rW   r   rT   r   rX   r   r   zLazyFrame[IntoLazyFrameT])rN   r)   r3   r   rW   r   rT   r   rX   r   r   r   )rN   r)   r3   r   rW   r   rT   r   rX   r   r   r   )rN   zIntoFrame | IntoSeriesr3   r   rW   r   rT   r   rX   r   r   z-DataFrame[Any] | LazyFrame[Any] | Series[Any])rN   r.   r3   r   rW   r   rT   r   rX   r   r   r   )rN   r   r3   r   rW   r   rT   r   rX   bool | Noner   r   )rN   zFIntoLazyFrameT | IntoFrameT | IntoSeriesT | IntoFrame | IntoSeries | Tr3   r   rW   r   rT   r   rX   r   rO   r   r   zKLazyFrame[IntoLazyFrameT] | DataFrame[IntoFrameT] | Series[IntoSeriesT] | T)rN   r   r3   r   rW   r   rj   r   rT   r   rX   r   rk   r   r   r   )r   zFDataFrame[Any] | LazyFrame[Any] | Series[Any] | IntoFrame | IntoSeriesr   r   r5   )r   zCallable[..., Any] | Noner3   r   rW   r   rT   r   rX   r   r   r   )r   r   r   r   )r   r   r   r   )M
__future__r   datetimer   decimalr   	functoolsr   typingr   r   r	   r
   r   r   narwhals._constantsr   r   narwhals._namespacer   r   r   r   r{   r   r   r   narwhals.dependenciesr   r   r   r   r   r   r   r   r   r   r    r!   r"   rB   r$   r%   rC   r'   narwhals.typingr(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r   bytesstrintfloatcomplexr   dater   timer   r:   rP   rn   r   r   r   r   r   __all__r6   r;   r9   <module>r      sg   "    K K 4  J I     7&
 
 
 CL!5#sE7GL ",,8  
RU.AO 
 
NQ*=K 
 
LO(;I 
 
 F 
 F 
  5B 
 D 
 D 
 J 
 J 
 J 
 J 
 #&:/:  : 	:
  :  : 5: 
: 

 "%"%$!$  $ 	$
  $ $ $ 
$ 

 "%"%   	
     
 
 #&$!$  $ 	$
  $ $ $ 
$ 
 #&   	
     
 

 "%"%R<R  R 	R
  R  R MR 
R 

 "%   	
    
 
 $'!$"%$!$ !$ 	$
  $ $ $ 
$ 
 $'!$"%$!$ !$ 	$
  $ $ $ 
$ 
 $'"%$!$ !$ 	$
  $ $ $ 
$ 
 $'!$"%8)8 !8 	8
  8  8 38 
8 
 $'!$ ! 	
    
 
  	
   	 
  $3Y3 3 	3
 3 3 3 Q3r &+ $__ _ 	_  $_ _ _ _ 	_D
PD+	O++ '+e  $e
#e e 	e
 e e eP8vW Nr;   