Ë
    z�h�  ã                  ó”  — 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	 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 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 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 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# 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) d d%lm*Z* d d&l+m,Z, e	rHd d'l-m.Z. d d(l-m/Z/ d d)l0m1Z1 d d*l2m3Z3 d d+l2m4Z4 d d,l2m5Z5 d d-l2m6Z6 d d.l2m7Z7 d d/l2m8Z8 d d0l2m9Z9 d d1l2m:Z: d d2l2m;Z;  ed3«      Z<e=e>e?e@eAeBefZCed4d5œ	 	 	 	 	 dad6„«       ZDed4d5œ	 	 	 	 	 dbd7„«       ZDed4d5œ	 	 	 	 	 dcd8„«       ZDeddd9„«       ZDd:d:d;œ	 	 	 	 	 	 	 ded<„ZDedfd=„«       ZEedgd>„«       ZEedhd?„«       ZEed4d@œ	 	 	 	 	 	 	 	 	 	 	 didA„«       ZEed4d4d4dBœ	 	 	 	 	 	 	 	 	 	 	 djdC„«       ZEed4d4d4dBœ	 	 	 	 	 	 	 	 	 	 	 dkdD„«       ZEed4d4dEœ	 	 	 	 	 	 	 	 	 	 	 dldF„«       ZEed4d4dEœ	 	 	 	 	 	 	 	 	 	 	 dmdG„«       ZEed4d4dHœ	 	 	 	 	 	 	 	 	 	 	 dndI„«       ZEed4d4dJœ	 	 	 	 	 	 	 	 	 	 	 dodK„«       ZEed4d4d4d4dLœ	 	 	 	 	 	 	 	 	 	 	 dpdM„«       ZEed4d4d4d4dLœ	 	 	 	 	 	 	 	 	 	 	 dqdN„«       ZEed4d4d4dOœ	 	 	 	 	 	 	 	 	 	 	 drdP„«       ZEed4d4d4dQœ	 	 	 	 	 	 	 	 	 	 	 dsdR„«       ZEed4d4d4dSœ	 	 	 	 	 	 	 	 	 	 	 dtdT„«       ZEe	 	 	 	 	 	 	 	 	 	 	 	 dudU„«       ZEd:d:dVdVd:dWœ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dvdX„ZEdVdVdVdVd:dYœ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dwdZ„ZF	 	 	 	 dxd[„ZG	 	 	 	 dxd\„ZH	 dyd:d:dVdVd]dWœ	 	 	 	 	 	 	 	 	 	 	 	 	 dzd^„ZId{d_„ZJg d`¢ZKy:)|é    )Úannotations)Údatetime)Ú	timedelta)ÚDecimal©Úwraps)ÚTYPE_CHECKING)ÚAny)ÚCallable)ÚLiteral)ÚTypeVar)Úoverload)Úis_native_arrow)Úis_native_polars)Úis_native_spark_like)Úget_cudf)Úget_cupy)Úget_dask)Úget_dask_expr)Ú	get_modin)Ú	get_numpy)Ú
get_pandas)Ú
get_polars)Úget_pyarrow)Úis_cudf_dataframe)Úis_cudf_series)Úis_dask_dataframe)Úis_duckdb_relation)Úis_ibis_table)Úis_modin_dataframe)Úis_modin_series)Úis_pandas_dataframe)Úis_pandas_series)Úis_polars_dataframe)Úis_polars_lazyframe)Úis_polars_series)Úis_pyarrow_chunked_array)Úis_pyarrow_table)ÚVersion©Ú	DataFrame©Ú	LazyFrame©ÚSeries)Ú
DataFrameT)ÚIntoDataFrameT)Ú	IntoFrame)Ú
IntoFrameT)ÚIntoLazyFrameT)Ú
IntoSeries)ÚIntoSeriesT)Ú
LazyFrameT)ÚSeriesTÚT.©Úpass_throughc                ó   — y ©N© ©Únarwhals_objectr;   s     úP/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/narwhals/translate.pyÚ	to_nativerB   E   s   € ð ó    c                ó   — y r=   r>   r?   s     rA   rB   rB   I   s   € ð rC   c                ó   — y r=   r>   r?   s     rA   rB   rB   M   s   € ð rC   c                ó   — y r=   r>   r?   s     rA   rB   rB   Q   s   € ØCFrC   N)Ústrictr;   c               ó  — ddl m} ddlm} ddlm}  |||dd¬«      }t        | |«      r| j                  j                  S t        | |«      r| j                  j                  S |sdt        | «      › d	�}t        |«      ‚| S )
a<  Convert Narwhals object to native one.

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

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

            **Deprecated** (v1.13.0):
                Please use `pass_through` instead. Note that `strict` is still available
                (and won't emit a deprecation warning) if you use `narwhals.stable.v1`,
                see [perfect backwards compatibility policy](../backcompat.md/).
        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.   ©Úvalidate_strict_and_pass_thoughFT©Úpass_through_defaultÚemit_deprecation_warningzExpected Narwhals object, got ú.)Únarwhals.dataframerI   Únarwhals.seriesr/   Únarwhals.utilsrK   Ú
isinstanceÚ_compliant_frameÚ_native_frameÚ_compliant_seriesÚnativeÚtypeÚ	TypeError)r@   rG   r;   rI   r/   rK   Úmsgs          rA   rB   rB   U   s‚   € õ: -Ý&Ý>á2Ø�°5ÐSWô€Lô �/ 9Ô-Ø×/Ñ/×=Ñ=Ð=Ü�/ 6Ô*Ø×0Ñ0×7Ñ7Ð7áØ.¬t°OÓ/DÐ.EÀQÐGˆÜ˜‹nÐØÐrC   c                 ó   — y r=   r>   ©Únative_objectÚkwdss     rA   Úfrom_nativer_   …   s   € ØADrC   c                 ó   — y r=   r>   r\   s     rA   r_   r_   ‰   ó   € ØGJrC   c                 ó   — y r=   r>   r\   s     rA   r_   r_   �   ra   rC   )Úseries_onlyc                ó   — y r=   r>   ©r]   r;   Ú
eager_onlyrc   Úallow_seriess        rA   r_   r_   ‘   s   € ð 7:rC   )rf   rc   rg   c                ó   — y r=   r>   re   s        rA   r_   r_   œ   ó   € ð !$rC   c                ó   — y r=   r>   re   s        rA   r_   r_   §   ó   € ð 	rC   )rc   rg   c                ó   — y r=   r>   re   s        rA   r_   r_   ²   ri   rC   c                ó   — y r=   r>   re   s        rA   r_   r_   ½   rk   rC   )rf   rc   c                ó   — y r=   r>   re   s        rA   r_   r_   È   s	   € ð ORrC   )rf   rg   c                ó   — y r=   r>   re   s        rA   r_   r_   Ó   ó   € ð rC   ©r;   rf   rc   rg   c                ó   — y r=   r>   re   s        rA   r_   r_   á   ri   rC   c                ó   — y r=   r>   re   s        rA   r_   r_   ì   ri   rC   )r;   rc   rg   c                ó   — y r=   r>   re   s        rA   r_   r_   ÷   ri   rC   )r;   rf   rc   c                ó   — y r=   r>   re   s        rA   r_   r_     s   € ð 58rC   )r;   rf   rg   c                ó   — y r=   r>   re   s        rA   r_   r_     rp   rC   c                ó   — y r=   r>   re   s        rA   r_   r_     s   € ð rC   F)rG   r;   rf   rc   rg   c          	     ó®   — ddl m}  |||dd¬«      }|r"dt        t        |«      «      ›�}t	        |«      ‚t        | ||d||t        j                  ¬«      S )a…  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__`
        strict: Determine what happens if the object can't be converted to Narwhals:

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

            **Deprecated** (v1.13.0):
                Please use `pass_through` instead. Note that `strict` is still available
                (and won't emit a deprecation warning) if you use `narwhals.stable.v1`,
                see [perfect backwards compatibility policy](../backcompat.md/).
        pass_through: Determine what happens if the object can't be converted to Narwhals:

            - `False` or `None` (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.
    r   rJ   FTrL   z1from_native() got an unexpected keyword argument )r;   rf   Úeager_or_interchange_onlyrc   rg   Úversion)rR   rK   ÚnextÚiterrY   Ú_from_native_implr)   ÚMAIN)	r]   rG   r;   rf   rc   rg   r^   rK   rZ   s	            rA   r_   r_   $  sg   € õb ?á2Ø�°5ÐSWô€Lñ ØAÄ$ÄtÈDÃzÓBRÐAUÐVˆÜ˜‹nÐäØØ!ØØ"'ØØ!Ü—‘ôð rC   )r;   rf   ry   rc   rg   c          	     óü  — ddl m} ddl m} ddlm}	 ddlm}
 ddlm} ddlm} ddlm	} dd	lm
} dd
lm} t        | ||f«      r|s| S t        | |	«      r|s|r| S |r|du rd}t        |«      ‚d}|r|rd}t        |«      ‚ || «      r+|r|sd}t        |«      ‚| S  || j                  «       d¬«      S  || «      r@|r|sd}t        |«      ‚| S |s|r|sd}t        |«      ‚| S  || j!                  «       d¬«      S  || «      r+|s|sd}t        |«      ‚| S  |	| j#                  «       d¬«      S t%        | «      rÑddlm} |r2t+        | «      s'|s#dt-        | «      j.                  › �}t        |«      ‚| S |s|rt1        | «      r|sd}t        |«      ‚| S |st+        | «      r|sd}t        |«      ‚| S  |t3        «       «      } |||¬«      }|j5                  | «      } ||«      r
 ||d¬«      S  ||«      r
 ||d¬«      S  |	|d¬«      S t7        | «      rHddlm} |r|sd}t        |«      ‚| S t=        «       } | ||  ||«      |
j>                  |d¬«      d¬«      S tA        | «      rGddl!m"} |s|sd}t        |«      ‚| S t=        «       } |	 || |
j>                   ||«      |¬«      d¬«      S tG        | «      rHddlm} tI        «       }|r|sd}t        |«      ‚| S  | || |
jJ                   ||«      |d¬«      d¬«      S tM        | «      rGddl!m"} tI        «       }|s|sd}t        |«      ‚| S  |	 || |
jJ                   ||«      |¬«      d¬«      S tO        | «      rHddlm} tQ        «       }|r|sd }t        |«      ‚| S  | || |
jR                   ||«      |d¬«      d¬«      S tU        | «      rGddl!m"} tQ        «       }|s|sd}t        |«      ‚| S  |	 || |
jR                   ||«      |¬«      d¬«      S tW        | «      r¢|r2tY        | «      r'|s#dt-        | «      j.                  › �}t        |«      ‚| S |stY        | «      s|sd}t        |«      ‚| S |jZ                  j]                  | «      j^                  j5                  | «      } ||«      r
 ||d¬«      S  |	|d¬«      S ta        | «      r}dd!l1m2} |r|sd"}t        |«      ‚| S |s|r|sd#}t        |«      ‚| S  |tg        «       «      }|d$k  rti        «       €d%}tk        |«      ‚ |||¬«      } ||j5                  | «      d¬«      S tm        | «      ro|s|r|sd&}t        |«      ‚| S |jZ                  j]                  | «      j^                  j5                  | «      }|tn        jp                  u r
 ||d'¬«      S  ||d¬«      S ts        | «      r_dd(l:m;} |s|r|sd)}t        |«      ‚| S dd l<}  || «      }!|tn        jp                  u r | || |!|¬«      d'¬«      S  | || |!|¬«      d¬«      S t{        | «      rŽ|jZ                  j]                  | «      }"|r%d|"j|                  j~                  › d*�}t        |«      ‚|s|r%d+|"j|                  j~                  › d*�}t        |«      ‚ ||"j^                  j5                  | «      d¬«      S  || «      r-dd,l@mA}# |s|r|sd-}t        |«      ‚| S  | |#| |¬.«      d'¬«      S |sd/t-        | «      › �}t        |«      ‚| S )0Nr   r*   r,   r.   )ÚImplementation)Ú_supports_dataframe_interchange)Úis_compliant_dataframe)Úis_compliant_lazyframe)Úis_compliant_series)Úparse_versionFzJInvalid 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`)ÚPolarsNamespacez#Cannot only use `series_only` with zQCannot only use `eager_only` or `eager_or_interchange_only` with polars.LazyFrame)Úbackend_versionrz   Úlazy)ÚPandasLikeDataFrame)r‰   Úimplementationrz   Úvalidate_column_names)ÚPandasLikeSeries)rŒ   r‰   rz   z2Cannot only use `series_only` with modin.DataFrame)rŒ   r‰   rz   r�   z1Cannot only use `series_only` with cudf.DataFrame)ÚDaskNamespacez1Cannot 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 DuckDBPyRelationÚinterchange)ÚIbisLazyFramezHCannot only use `series_only=True` or `eager_only=False` with Ibis tablez
 DataFramezACannot only use `eager_only` or `eager_or_interchange_only` with )ÚInterchangeFramezhCannot only use `series_only=True` or `eager_only=False` with object which only implements __dataframe__)rz   zLExpected pandas-like dataframe, Polars dataframe, or Polars lazyframe, got: )BrP   r+   r-   rQ   r/   rR   r€   r�   r‚   rƒ   r„   r…   rS   Ú
ValueErrorrY   Ú__narwhals_dataframe__Ú__narwhals_lazyframe__Ú__narwhals_series__r   Únarwhals._polars.namespacerˆ   r&   rX   Ú__qualname__r%   r   r_   r"   Únarwhals._pandas_like.dataframer‹   r   ÚPANDASr#   Únarwhals._pandas_like.seriesrŽ   r    r   ÚMODINr!   r   r   ÚCUDFr   r   r(   Ú	namespaceÚfrom_native_objectÚ	compliantr   Únarwhals._dask.namespacer�   r   r   ÚImportErrorr   r)   ÚV1r   Únarwhals._ibis.dataframer“   Úibisr   rŒ   Ú_aliasÚnarwhals._interchange.dataframer”   )$r]   r;   rf   ry   rc   rg   rz   r+   r-   r/   r€   r�   r‚   rƒ   r„   r…   rZ   rˆ   Ú
pl_versionÚpl_nsÚpl_compliantr‹   ÚpdrŽ   ÚmpdÚcudfÚpa_compliantr�   Údask_versionÚdd_nsÚduckdb_compliantr“   r§   r‰   Úns_sparkr”   s$                                       rA   r}   r}   i  sõ  € õ -Ý,Ý&Ý-Ý>Ý5Ý5Ý2Ý,ô �- )¨YÐ!7Ô8ÁØÐÜ�- Ô(©k¹\ØÐáØ˜5Ñ Ø^ˆCÜ˜S“/Ð!ØˆÙÑ/ØeˆÜ˜‹oÐñ ˜mÔ,ÙÙØD�Ü “nÐ$Ø Ð ÙØ×0Ñ0Ó2Øô
ð 	
ñ 
  Ô	.ÙÙØD�Ü “nÐ$Ø Ð ÙÑ2ÙØb�Ü “nÐ$Ø Ð ÙØ×0Ñ0Ó2Øô
ð 	
ñ 
˜]Ô	+ÙÙØL�Ü “nÐ$Ø Ð ÙØ×-Ñ-Ó/Øô
ð 	
ô 
˜-Ô	(Ý>áÔ/°Ô>ÙØ;¼DÀÓ<O×<\Ñ<\Ð;]Ð^�Ü “nÐ$Ø Ð ÙÑ3Ô9LØô:
ñ  Øi�Ü “nÐ$Ø Ð ÙÔ"2°=Ô"AÙØL�Ü “nÐ$Ø Ð Ù"¤:£<Ó0ˆ
Ù°
ÀGÔLˆØ×(Ñ(¨Ó7ˆÙ! ,Ô/Ù˜\°Ô8Ð8Ù# LÔ1Ù˜\°Ô8Ð8Ù�l¨&Ô1Ð1ô 
˜]Ô	+ÝGáÙØD�Ü “nÐ$Ø Ð Ü‹\ˆÙÙØÙ -¨bÓ 1Ø-×4Ñ4ØØ&*ôð ô	
ð 		
ô 
˜-Ô	(ÝAáÙØL�Ü “nÐ$Ø Ð Ü‹\ˆÙÙØØ-×4Ñ4Ù -¨bÓ 1Øô	ð ô
ð 	
ô 
˜MÔ	*ÝGä‹kˆÙÙØJ�Ü “nÐ$Ø Ð ÙÙØØ-×3Ñ3Ù -¨cÓ 2ØØ&*ôð ô	
ð 		
ô 
˜Ô	'ÝAä‹kˆÙÙØL�Ü “nÐ$Ø Ð ÙÙØØ-×3Ñ3Ù -¨cÓ 2Øô	ð ô
ð 	
ô 
˜=Ô	)ÝGä‹zˆÙÙØI�Ü “nÐ$Ø Ð ÙÙØØ-×2Ñ2Ù -¨dÓ 3ØØ&*ôð ô	
ð 		
ô 
˜Ô	&ÝAä‹zˆÙÙØL�Ü “nÐ$Ø Ð ÙÙØØ-×2Ñ2Ù -¨dÓ 3Øô	ð ô
ð 	
ô 
˜Ô	'ÙÔ+¨MÔ:ÙØ;¼DÀÓ<O×<\Ñ<\Ð;]Ð^�Ü “nÐ$Ø Ð ÙÔ$4°]Ô$CÙØL�Ü “nÐ$Ø Ð Ø×(Ñ(×;Ñ;Øó
ç
‰)—K‘K Ó.ð 	ñ " ,Ô/Ù˜\°Ô8Ð8Ù�l¨&Ô1Ð1ô 
˜=Ô	)Ý:áÙØI�Ü “nÐ$Ø Ð ÙÑ2ÙØg�Ü “nÐ$Ø Ð Ù$¤X£ZÓ0ˆØ˜=Ò(¬]«_Ð-DØ,ˆCÜ˜cÓ"Ð"Ù¨lÀGÔLˆÙ˜×*Ñ*¨=Ó9ÀÔHÐHô 
˜MÔ	*Ù™ÙØf�Ü “nÐ$Ø Ð Ø"×,Ñ,×?Ñ?Øó
ç
‰)—K‘K Ó.ð 	ð ”g—j‘jÑ ÙÐ-°]ÔCÐCÙÐ)°Ô8Ð8ô 
�}Ô	%Ý:á™Ùð&ð ô   “nÐ$Ø Ð Ûá'¨Ó-ˆØ”g—j‘jÑ ÙÙØ!°?ÈGôð $ô	ð ñ ÙØ¨Èôð ô	
ð 	
ô 
˜mÔ	,Ø×$Ñ$×7Ñ7¸ÓFˆÙØ7¸×8OÑ8O×8VÑ8VÐ7WÐWaÐbˆCÜ˜C“.Ð ÙÑ2ØUÐV^×VmÑVm×VtÑVtÐUuÐuð  AˆCÜ˜C“.Ð Ù˜×+Ñ+×7Ñ7¸ÓFÈfÔUÐUñ 
)¨Ô	7ÝDá™ÙðFð ô   “nÐ$Ø Ð ÙÙ˜]°GÔ<Øô
ð 	
ñ
 Ø\Ô]aÐboÓ]pÐ\qÐrˆÜ˜‹nÐØÐrC   c                 ó¸   — | sd}t        |«      ‚| D �ch c]  }t        |«      ’Œ }}t        |«      dk7  rd|› d�}t        |«      ‚|j                  «       S c c}w )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`.r‘   z0Found objects with different native namespaces: rO   )r•   Ú _get_native_namespace_single_objÚlenÚpop)ÚobjrZ   ÚxÚresults       rA   Úget_native_namespacer¼   º  se   € ñ0 ØMˆÜ˜‹oÐØ;>Ö?°aÔ.¨qÕ1Ð?€FÐ?Ü
ˆ6ƒ{�aÒØ@ÀÀÈÐJˆÜ˜‹oÐØ�:‰:‹<Ðùò	 @s   ”Ac                óð  — ddl m}  || «      r| j                  «       S t        | «      st	        | «      r
t        «       S t        | «      st        | «      r
t        «       S t        | «      st        | «      r
t        «       S t        | «      st        | «      r
t        «       S t        | «      r
t!        «       S t#        | «      st%        | «      st'        | «      r
t)        «       S dt+        | «      › �}t-        |«      ‚)Nr   )Úhas_native_namespacez4Could not get native namespace from object of type: )rR   r¾   Ú__native_namespace__r"   r#   r   r    r!   r   r(   r'   r   r   r   r   r   r   r$   r%   r&   r   rX   rY   )r¹   r¾   rZ   s      rA   r¶   r¶   Ü  sÇ   € õ 4á˜CÔ Ø×'Ñ'Ó)Ð)Ü˜3ÔÔ#3°CÔ#8Ü‹|ÐÜ˜#Ô¤/°#Ô"6Ü‹{ÐÜ˜ÔÔ 8¸Ô =Ü‹}ÐÜ˜Ô¤°Ô!4Ü‹zÐÜ˜ÔÜ‹zÐÜ˜3ÔÔ#6°sÔ#;Ô?OÐPSÔ?TÜ‹|ÐØ@ÄÀcÃÀÐ
L€CÜ
�C‹.ÐrC   Tc               óX   ‡‡‡‡— ddl m}  ||‰dd¬«      Šdˆˆˆˆfd„}| €|S  || «      S )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.
        strict: **Deprecated** (v1.13.0):
            Please use `pass_through` instead. Note that `strict` is still available
            (and won't emit a deprecation warning) if you use `narwhals.stable.v1`,
            see [perfect backwards compatibility policy](../backcompat.md/).

            Determine what happens if the object can't be converted to Narwhals:

            - `True` or `None` (default): raise an error
            - `False`: pass object through as-is
        pass_through: Determine what happens if the object can't be converted to Narwhals:

            - `False` or `None` (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`: 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())
    r   rJ   TrL   c                ó:   •‡ — t        ‰ «      dˆˆˆ ˆˆfd„«       }|S )Nc                 óŒ  •— | D �cg c]  }t        |‰‰‰‰
¬«      ‘Œ } }|j                  «       D ��ci c]  \  }}|t        |‰‰‰‰
¬«      “Œ }}}g | ¢|j                  «       ¢­D �ch c]  }t        |dd «      x}r |«       ’Œ }}t	        |«      dkD  rd}t        |«      ‚ ‰| i |¤Ž}	t        |	‰¬«      S c c}w c c}}w c c}w )Nrq   r¿   r‘   z_Found multiple backends. Make sure that all dataframe/series inputs come from the same backend.r:   )r_   ÚitemsÚvaluesÚgetattrr·   r•   rB   )ÚargsÚkwargsÚargÚnameÚvalueÚvÚbÚbackendsrZ   r»   rg   rf   Úfuncr;   rc   s             €€€€€rA   Úwrapperz.narwhalify.<locals>.decorator.<locals>.wrapper;  s  ø€ ð  ö	ð ô ØØ!-Ø)Ø +Ø!-öð	ˆDð 	ð& $*§<¡<£>÷	ñ  �D˜%ð ”kØØ!-Ø)Ø +Ø!-ôñ ð	ˆFñ 	ð 3˜4Ð2 &§-¡-£/Ñ2öàÜ  Ð$:¸DÓAÐA�AÐAñ •ðˆHð ô �8‹}˜qÒ Øw�Ü  “oÐ%á˜4Ð* 6Ñ*ˆFä˜V°,Ô?Ð?ùòE	ùó	ùòs   †B6²B;Á'C)rÆ   r
   rÇ   r
   Úreturnr
   r   )rÎ   rÏ   rg   rf   r;   rc   s   ` €€€€rA   Ú	decoratorznarwhalify.<locals>.decorator:  s)   ù€ Ü	ˆt‹÷#	@ð #	@ó 
ð#	@ðJ ˆrC   )rÎ   úCallable[..., Any]rÐ   rÒ   )rR   rK   )rÎ   rG   r;   rf   rc   rg   rK   rÑ   s     ````  rA   Ú
narwhalifyrÓ   ó  sA   û€ õB ?á2Ø�°4ÐRVô€L÷'ð 'ðR €|ØÐñ ˜‹ÐrC   c                óÖ  — | €yt        | t        «      r| S t        «       }|rPt        | |j                  «      r:| j                  dk(  r+t        ddd«      t        | j                  «       dz  ¬«      z   S |r-|j                  | «      rt        | d«      r| j                  «       S t        «       }|r&t        | |j                  «      r| j                  «       S |r&t        | |j                  «      r| j                  «       S |r:|j                  j                   j#                  | «      r	 |j%                  | «      }|ryt        | t
        t        f«      r| S t)        «       }|r&t        | |j*                  «      r| j-                  «       S t/        «       }|r5t        | |j0                  «      r| j2                  dk(  r| j                  «       S dt5        | «      › d	�}t7        |«      ‚# t&        $ r Y Œ°w xY w)
au  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]i²  r‘   iè  )ÚmicrosecondsÚitemz/Expected object convertible to a scalar, found zH. Please report a bug to https://github.com/narwhals-dev/narwhals/issues)rS   ÚNON_TEMPORAL_SCALAR_TYPESr   Ú
datetime64Údtyper   r   rÖ   ÚisscalarÚhasattrr   Ú	TimestampÚto_pydatetimeÚ	TimedeltaÚto_pytimedeltaÚapiÚtypesÚ	is_scalarÚisnaÚ	Exceptionr   ÚScalarÚas_pyr   ÚndarrayÚsizerX   r•   )Úscalar_likeÚnpr­   Úis_naÚpaÚcupyrZ   s          rA   Úto_py_scalarrî   j  s¼  € ð2 ÐØÜ�+Ô8Ô9ØÐä	‹€Bá
Ü�{ B§M¡MÔ2Ø×ÑÐ!1Ò1ä˜˜a Ó#¤i¸[×=MÑ=MÓ=OÐSWÑ=WÔ&XÑXÐXá	ˆb�k‰k˜+Ô&¬7°;ÀÔ+GØ×ÑÓ!Ð!ä	‹€BÙ	Œj˜ b§l¡lÔ3Ø×(Ñ(Ó*Ð*Ù	Œj˜ b§l¡lÔ3Ø×)Ñ)Ó+Ð+Ù	ˆb�f‰f�l‰l×$Ñ$ [Ô1ð	Ø—G‘G˜KÓ(ˆEñ Øô �+¤¬)Ð4Ô5ØÐä	‹€BÙ	Œj˜ b§i¡iÔ0Ø× Ñ Ó"Ð"ä‹:€Dá”˜K¨¯©Ô6¸;×;KÑ;KÈqÒ;Pà×ÑÓ!Ð!ð :¼$¸{Ó:KÐ9Lð MQð 	Qð ô �S‹/Ðøô3 ò 	Ùð	ús   Ä#G Ç	G(Ç'G()r¼   rÓ   rB   rî   )r@   úDataFrame[IntoDataFrameT]r;   úLiteral[False]rÐ   r1   )r@   zLazyFrame[IntoFrameT]r;   rð   rÐ   r3   )r@   úSeries[IntoSeriesT]r;   rð   rÐ   r6   )r@   r
   r;   ÚboolrÐ   r
   )r@   zGDataFrame[IntoDataFrameT] | LazyFrame[IntoFrameT] | Series[IntoSeriesT]rG   úbool | Noner;   ró   rÐ   z/IntoDataFrameT | IntoFrameT | IntoSeriesT | Any)r]   r8   r^   r
   rÐ   r8   )r]   r0   r^   r
   rÐ   r0   )r]   r7   r^   r
   rÐ   r7   )r]   zIntoDataFrameT | IntoSeriesTr;   úLiteral[True]rf   rô   rc   rð   rg   rô   rÐ   z/DataFrame[IntoDataFrameT] | Series[IntoSeriesT])r]   r1   r;   rô   rf   rð   rc   rð   rg   ÚNonerÐ   rï   )r]   r9   r;   rô   rf   rð   rc   rð   rg   rõ   rÐ   r9   )r]   r1   r;   rô   rf   rô   rc   rð   rg   rõ   rÐ   rï   )r]   r9   r;   rô   rf   rô   rc   rð   rg   rõ   rÐ   r9   )r]   z)IntoFrameT | IntoLazyFrameT | IntoSeriesTr;   rô   rf   rð   rc   rð   rg   rô   rÐ   zGDataFrame[IntoFrameT] | LazyFrame[IntoLazyFrameT] | Series[IntoSeriesT])r]   r6   r;   rô   rf   rð   rc   rô   rg   rõ   rÐ   rñ   )r]   r4   r;   rð   rf   rð   rc   rð   rg   rõ   rÐ   zLazyFrame[IntoLazyFrameT])r]   r1   r;   rð   rf   rð   rc   rð   rg   rõ   rÐ   rï   )r]   r1   r;   rð   rf   rô   rc   rð   rg   rõ   rÐ   rï   )r]   zIntoFrame | IntoSeriesr;   rð   rf   rð   rc   rð   rg   rô   rÐ   z-DataFrame[Any] | LazyFrame[Any] | Series[Any])r]   r6   r;   rð   rf   rð   rc   rô   rg   rõ   rÐ   rñ   )r]   r
   r;   rò   rf   rò   rc   rò   rg   ró   rÐ   r
   )r]   zFIntoLazyFrameT | IntoFrameT | IntoSeriesT | IntoFrame | IntoSeries | TrG   ró   r;   ró   rf   rò   rc   rò   rg   ró   r^   r
   rÐ   zKLazyFrame[IntoLazyFrameT] | DataFrame[IntoFrameT] | Series[IntoSeriesT] | T)r]   r
   r;   rò   rf   rò   ry   rò   rc   rò   rg   ró   rz   r)   rÐ   r
   )r¹   zFDataFrame[Any] | LazyFrame[Any] | Series[Any] | IntoFrame | IntoSeriesrÐ   r
   r=   )rÎ   zCallable[..., Any] | NonerG   ró   r;   ró   rf   rò   rc   rò   rg   ró   rÐ   rÒ   )ré   r
   rÐ   r
   )LÚ
__future__r   r   r   Údecimalr   Ú	functoolsr   Útypingr	   r
   r   r   r   r   Únarwhals._namespacer   r   r   Únarwhals.dependenciesr   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   rR   r)   rP   r+   r-   rQ   r/   Únarwhals.typingr0   r1   r2   r3   r4   r5   r6   r7   r8   r9   rò   ÚbytesÚstrÚintÚfloatÚcomplexr×   rB   r_   r}   r¼   r¶   rÓ   rî   Ú__all__r>   rC   rA   ú<module>r     sÄ  ðÝ "å Ý Ý Ý Ý  Ý Ý Ý Ý Ý å /Ý 0Ý 4Ý *Ý *Ý *Ý /Ý +Ý +Ý ,Ý ,Ý -Ý 3Ý 0Ý 3Ý 4Ý /Ý 4Ý 1Ý 5Ý 2Ý 5Ý 5Ý 2Ý :Ý 2Ý "áÝ,Ý,Ý&Ý*Ý.Ý)Ý*Ý.Ý*Ý+Ý*Ý'áˆCƒL€ð 	Ø	ØØØ	ØØðÐ ð 
àRUñØ.ðØAOðàòó 
ðð 
àNQñØ*ðØ=Kðàòó 
ðð 
àLOñØ(ðØ;Iðàòó 
ðð 
Ú Fó 
Ø Fð Ø $ñ-ðð-ð
 ð-ð ð-ð 5ó-ð` 
Ú 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ð 
ð $'Ø!$àñØðð !ðð ð	ð
 ðð ðð òó 
ðð 
ðØðð ðð ð	ð
 ðð ðð 	òó 
ðð Ø $ØØØ $ñBØYðBð ðBð ð	Bð
 ðBð ðBð ðBð ðBð QóBðP Øà&+ØØ $ñNØðNð ðNð ð	Nð  $ðNð ðNð ðNð ðNð 	óNðb
Ø
PðàóðDØ	Oðàóð0 '+ðtð Ø $ØØØ $ñtØ
#ðtð ðtð ð	tð
 ðtð ðtð ðtð ótónJòZ�rC   