
    LpjD                    n   % S SK Jr  S SKJrJrJrJr  S SKJr  S SK	J
r
JrJrJr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  S SKJrJrJrJ r J!r!J"r"  S SK#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/J0r0J1r1  S S	K2J3r3  \
(       a  S S
K4J5r5  S SK6J7r7  S SK8J9r9  S SK	J:r:  S SK;r<S SK=r>S SK?r@S SKAJBrB  S SKCJDrDJErE  S SKFJGrG  S SKHJIrI  S SKJJrJ  S SKKJLrLJMrM  S SK%JNrNJOrO  S SKPJQrQ  S SKRJSrS  S SK2JTrT  S SKUJVrVJWrWJXrXJYrYJZrZJ[r[J\r\J]r]J^r^J_r_J`r`JaraJbrbJcrc  \rdS\eS'   SrfS\eS'   / SQrg\" S 5      rhS!riS\eS"'   \" S#5      rj " S$ S%\(\j   \\j   \!\"   \\\j\"4   5      rk " S& S'\ S(   \S)\\l\4   4   \S*   \\k\\\"4   \\\\\"4   5      rm " S+ S,\k\\\"4   \\\\"4   5      rn " S- S.\m\\\S/4   \n\SS/4   \&\\\\\4   5      rog)0    )annotations)IteratorMappingSequenceSized)chain)TYPE_CHECKINGAnyFinalLiteralProtocolTypeVaroverload)
CompliantDataFrameAnyCompliantExprT_contraCompliantLazyFrameAnyCompliantNamespaceAnyCompliantSeriesT
EagerExprTEagerSeriesTNativeDataFrameTNativeLazyFrameTNativeSeriesT)ArrowConvertibleDictConvertible
FromNativeNumpyConvertible
ToNarwhalsToNarwhalsT_co)assert_never)ValidateBackendVersionVersion_StoresNativecheck_columns_existis_boolean_selectoris_compliant_seriesis_index_selectoris_rangeis_sequence_likeis_sized_multi_index_selectoris_slice_indexis_slice_none)MultiOutputExpressionError)BytesIO)Path)
ModuleType)	TypeAliasN)Self)CompliantGroupByDataFrameGroupBy)EagerNamespace)SparkSession)IntoArrowTable)_EagerAllowedImpl_LazyAllowedImpl)Implementation_LimitedContext)	DataFrame)DType)ColumnNotFoundError)AsofJoinStrategy	IntoDTypeJoinStrategyMultiColSelectorMultiIndexSelectorPivotAggSingleIndexSelectorSizedMultiIndexSelectorSizedMultiNameSelectorSizeUnitUniqueKeepStrategy_2DArray_SliceIndex
_SliceNamer1   
IncompleteFr   MYPY)CompliantDataFrameCompliantFrameCompliantLazyFrameEagerDataFrameT2dict[str, CompliantSeriesT] | dict[str, list[Any]]_ToDict_NativeFrameTc                     \ rS rSr% SrS\S'   S\S'   S\S'   S$S	 jrS%S
 jrS&S jrS'S jr	\
S(S j5       r\S)S j5       r\S*S j5       r\S+S j5       rS+S jrS,S jrS-S jrS.S jrS/S jr      S0S jrS1S jr            S2S jr                S3S jrS4S jrS5S jrS6S jr        S7S jr        S8S jr          S9S jrS5S  jrS:S! jr S"r!g#);rP   ^   z)Common parts of `DataFrame`, `LazyFrame`.rV   _native_framer:   _implementationr"   _versionc                    g N selfs    Y/var/www/html/pdf-tiff/venv/lib/python3.13/site-packages/narwhals/_compliant/dataframe.py__native_namespace__#CompliantFrame.__native_namespace__j       #    c                    g r]   r^   r_   s    ra   __narwhals_namespace__%CompliantFrame.__narwhals_namespace__k       Sre   c                    g r]   r^   )r`   dfs     ra   _with_nativeCompliantFrame._with_nativel       sre   c                    g r]   r^   )r`   versions     ra   _with_versionCompliantFrame._with_versionm   rn   re   c                  g r]   r^   clsdatacontexts      ra   from_nativeCompliantFrame.from_nativen       WZre   c                    g r]   r^   r_   s    ra   columnsCompliantFrame.columnsp       (+re   c                    U R                   $ r]   )rY   r_   s    ra   nativeCompliantFrame.nativer   s    !!!re   c                    g r]   r^   r_   s    ra   schemaCompliantFrame.schemav   s    -0re   c                    g r]   r^   r_   s    ra   collect_schemaCompliantFrame.collect_schemay   s    Sre   c                   g r]   r^   )r`   r|   stricts      ra   dropCompliantFrame.dropz   s    Sre   c                    g r]   r^   r`   subsets     ra   
drop_nullsCompliantFrame.drop_nulls{       re   c                    g r]   r^   r`   r|   s     ra   explodeCompliantFrame.explode|   rn   re   c                    g r]   r^   )r`   	predicates     ra   filterCompliantFrame.filter}       Sre   c                   g r]   r^   r`   keysdrop_null_keyss      ra   group_byCompliantFrame.group_by~   s    
 9<re   c                    g r]   r^   )r`   ns     ra   headCompliantFrame.head       Cre   c                   g r]   r^   )r`   otherhowleft_onright_onsuffixs         ra   joinCompliantFrame.join        re   c                   g r]   r^   )r`   r   r   r   by_leftby_rightstrategyr   s           ra   	join_asofCompliantFrame.join_asof   s     re   c                    g r]   r^   )r`   mappings     ra   renameCompliantFrame.rename       #re   c                    g r]   r^   r`   exprss     ra   selectCompliantFrame.select       Sre   c                    g)z)`select` where all args are column names.Nr^   )r`   column_namess     ra   simple_selectCompliantFrame.simple_select       re   c                   g r]   r^   )r`   
descending
nulls_lastbys       ra   sortCompliantFrame.sort       re   c                   g r]   r^   )r`   r   keeporder_bys       ra   uniqueCompliantFrame.unique        re   c                    g r]   r^   )r`   onindexvariable_name
value_names        ra   unpivotCompliantFrame.unpivot   r   re   c                    g r]   r^   r   s     ra   with_columnsCompliantFrame.with_columns   s    3re   c                    g r]   r^   r`   namer   s      ra   with_row_indexCompliantFrame.with_row_index       #re   r^   N)returnr0   )r   r
   )rk   rV   r   r2   )rp   r"   r   r2   )rv   rV   rw   r;   r   r2   )r   Sequence[str])r   rV   )r   zMapping[str, DType])r|   r   r   boolr   r2   )r   Sequence[str] | Noner   r2   )r|   r   r   r2   )r   z"CompliantExprT_contra | Incompleter   r2   )r   /Sequence[str] | Sequence[CompliantExprT_contra]r   r   r   z-CompliantGroupBy[Self, CompliantExprT_contra])r   intr   r2   )r   r2   r   rA   r   r   r   r   r   strr   r2   )r   r2   r   r   r   r   r   r   r   r   r   r?   r   r   r   r2   )r   zMapping[str, str]r   r2   r   r   r   r2   )r   r   r   r2   )r   r   r   zbool | Sequence[bool]r   r   r   r2   )r   r   r   rI   r   r   r   r2   )
r   r   r   r   r   r   r   r   r   r2   )r   r   r   r   r   r2   )"__name__
__module____qualname____firstlineno____doc____annotations__rb   rg   rl   rq   classmethodrx   propertyr|   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   __static_attributes__r^   re   ra   rP   rP   ^   s    4  ##50::Z Z+ +" " 0 08HC:P<=< 	<
 
7< ( 	
 & '  


 	

 
 &
 '
 #
 
 

 >@$9GK	$ !	
 ' 
  $ 	
  
 GMre   rP   c                  d   \ rS rSrS'S jr\S(S j5       r\        S)S j5       r\        S*S j5       r\        S+S j5       r	S,S jr
    S-S jr\S.S	 j5       rS'S
 jrS/S jrS0S jrS1S jr      S2S jrS3S jrS4S jr      S5S jrS6S jr      S7S jr              S8S jrS9S jr    S:S jrS;S jrS<S jrS=S jrS>S jr\S?S j5       r \S@S j5       r     SAS jr SS.         SBS  jjr!SCS! jr"\SDS" j5       r#\SES# j5       r#SFS$ jr#SES% jr$S&r%g)GrO      c                    g r]   r^   r_   s    ra   __narwhals_dataframe__)CompliantDataFrame.__narwhals_dataframe__       cre   c                  g r]   r^   rt   s      ra   
from_arrowCompliantDataFrame.from_arrow   rz   re   c                  g r]   r^   ru   rv   rw   r   s       ra   	from_dictCompliantDataFrame.from_dict   r   re   c                  g r]   r^   r   s       ra   
from_dictsCompliantDataFrame.from_dicts   r   re   c                  g r]   r^   r   s       ra   
from_numpyCompliantDataFrame.from_numpy   r   re   c                   g r]   r^   )r`   dtypecopys      ra   	__array__CompliantDataFrame.__array__   s    sre   c                    g r]   r^   )r`   items     ra   __getitem__CompliantDataFrame.__getitem__   r   re   c                    g r]   r^   r_   s    ra   shapeCompliantDataFrame.shape   r~   re   c                    g r]   r^   r_   s    ra   cloneCompliantDataFrame.clone   s    Sre   c                    g r]   r^   )r`   units     ra   estimated_size!CompliantDataFrame.estimated_size   r   re   c                    g r]   r^   )r`   r   offsets      ra   gather_everyCompliantDataFrame.gather_every       re   c                    g r]   r^   )r`   r   s     ra   
get_columnCompliantDataFrame.get_column   r  re   c                   g r]   r^   r   s      ra   r   CompliantDataFrame.group_by   s    
 '*re   c                    g r]   r^   )r`   rowcolumns      ra   r  CompliantDataFrame.item   s    cre   c                    g r]   r^   r_   s    ra   iter_columnsCompliantDataFrame.iter_columns   r   re   c                   g r]   r^   )r`   namedbuffer_sizes      ra   	iter_rowsCompliantDataFrame.iter_rows       BEre   c                    g r]   r^   r_   s    ra   	is_uniqueCompliantDataFrame.is_unique   ri   re   c                   g r]   r^   )r`   backendsessions      ra   lazyCompliantDataFrame.lazy        #re   c                   g r]   r^   )r`   r   r   valuesaggregate_functionsort_columns	separators          ra   pivotCompliantDataFrame.pivot   s     re   c                    g r]   r^   )r`   r   s     ra   r$  CompliantDataFrame.row  rd   re   c                   g r]   r^   )r`   r+  s     ra   rowsCompliantDataFrame.rows  r/  re   c                   g r]   r^   )r`   r   with_replacementseeds       ra   sampleCompliantDataFrame.sample  s    SVre   c                    g r]   r^   r_   s    ra   to_arrowCompliantDataFrame.to_arrow  r   re   c                    g r]   r^   r_   s    ra   	to_pandasCompliantDataFrame.to_pandas      re   c                    g r]   r^   r_   s    ra   	to_polarsCompliantDataFrame.to_polars	  rP  re   c                   g r]   r^   r`   	as_seriess     ra   to_dictCompliantDataFrame.to_dict
  s    SVre   c                   g r]   r^   rU  s     ra   rW  rX    s    MPre   c                   g r]   r^   rU  s     ra   rW  rX    s    =@re   N)maintain_orderc                   g r]   r^   )r`   r   r   r[  r   s        ra   r   CompliantDataFrame.unique  s     re   c                    g r]   r^   r   s      ra   r   !CompliantDataFrame.with_row_index  s    QTre   c                    g r]   r^   r`   files     ra   	write_csvCompliantDataFrame.write_csv  s    ,/re   c                    g r]   r^   ra  s     ra   rc  rd    s    =@re   c                    g r]   r^   ra  s     ra   rc  rd    r   re   c                    g r]   r^   ra  s     ra   write_parquet CompliantDataFrame.write_parquet  s    re   r^   r   r2   )rv   r7   rw   r;   r   r2   )rv   zMapping[str, Any]rw   r   r   %Mapping[str, IntoDType | None] | Noner   r2   )rv   zSequence[Mapping[str, Any]]rw   r;   r   rk  r   r2   )rv   rJ   rw   r;   r   z.Mapping[str, IntoDType] | Sequence[str] | Noner   r2   )r  r
   r  bool | Noner   rJ   )r  zetuple[SingleIndexSelector | MultiIndexSelector[CompliantSeriesT], MultiColSelector[CompliantSeriesT]]r   r2   )r   ztuple[int, int])r  rH   r   zint | float)r   r   r  r   r   r2   )r   r   r   r   )r   r   r   r   r   zDataFrameGroupBy[Self, Any])r$  
int | Noner%  zint | str | Noner   r
   )r   zIterator[CompliantSeriesT])r+  r   r,  r   r   z7Iterator[tuple[Any, ...]] | Iterator[Mapping[str, Any]])r   r   )r4  z_LazyAllowedImpl | Noner5  zSparkSession | Noner   r   )r   r   r   r   r:  r   r;  zPivotAgg | Noner<  r   r=  r   r   r2   )r   r   r   ztuple[Any, ...])r+  r   r   z7Sequence[tuple[Any, ...]] | Sequence[Mapping[str, Any]])r   r   rF  r   rG  rm  r   r2   )r   pa.Table)r   zpd.DataFrame)r   zpl.DataFrame)rV  zLiteral[True]r   zdict[str, CompliantSeriesT])rV  zLiteral[False]r   zdict[str, list[Any]])rV  r   r   rT   )
r   r   r   rI   r[  rl  r   r   r   r2   )r   r   r   r   r   r2   )rb  Noner   r   rb  zstr | Path | BytesIOr   ro  )rb  zstr | Path | BytesIO | Noner   z
str | None)&r   r   r   r   r   r   r   r   r  r  r	  r  r   r  r  r  r  r  r   r  r(  r-  r1  r6  r>  r$  rC  rH  rK  rN  rR  r   rW  r   r   rc  rh  r   r^   re   ra   rO   rO      st    2Z Z
 ' 6 
  )
 ! 6 
  
 ! ? 
  K
 
 + + @<<*=* 	*
 
%* J=FF+.F	@F 1$.$<O$	$		 $		
 %	 ,	 	 	 
	 6FF	@F W',,V VP PA A	;A '+$ !	
 $ ' 
 U/ /@ @MDre   rO   )rJ   rJ   z_ToDict[CompliantSeriesT])rn  r7   c                  R    \ 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Sr	g)rQ   i"  c                    g r]   r^   r_   s    ra   __narwhals_lazyframe__)CompliantLazyFrame.__narwhals_lazyframe__&  r   re   c                    g r]   r^   r_   s    ra   _iter_columns CompliantLazyFrame._iter_columns(  r   re   c                    g)z[`select` where all args are aggregations or literals.

(so, no broadcasting is necessary).
Nr^   r   s     ra   	aggregateCompliantLazyFrame.aggregate)  s    
 	re   c                    g r]   r^   )r`   r4  kwargss      ra   collectCompliantLazyFrame.collect0  r8  re   c                    g r]   r^   ra  s     ra   sink_parquetCompliantLazyFrame.sink_parquet3  r   re   r^   Nrj  )r   zIterator[Any]r   )r4  z_EagerAllowedImpl | Noner|  r
   r   r   rp  )
r   r   r   r   rs  rv  ry  r}  r  r   r^   re   ra   rQ   rQ   "  s2     21$/$;>$	$ Dre   rQ   c                      \ rS rSr\SS j5       r  SS jrSS jrSS jrSS.     SS jjr	SS	 jr
SS
 jrS S jrS!S jrS"S jr\      S#S j5       rS$S jrS%S jr    S&S jr    S'S jrS(S jrS)S jr    S*S jrS+S jrSrg),rR   i6  c                6    U R                   R                  5       $ r]   )rZ   _backend_versionr_   s    ra   r  EagerDataFrame._backend_version>  s    ##4466re   c                    g r]   r^   r_   s    ra   rg   %EagerDataFrame.__narwhals_namespace__B  s     re   c                6    U R                   R                  U SS9$ )Nfull)level)r[   	dataframer_   s    ra   to_narwhalsEagerDataFrame.to_narwhalsH  s    }}&&t6&::re   c                     U R                   " U6 $ r]   )r   r   s     ra   ry  EagerDataFrame.aggregateK  s     {{E""re   T)validate_column_namesc                   g r]   r^   )r`   rk   r  s      ra   rl   EagerDataFrame._with_nativeU  r   re   c                (    [        XR                  S9$ )N)	available)r$   r|   r   s     ra   _check_columns_exist#EagerDataFrame._check_columns_existY  s    "6\\BBre   c               f    U R                  U5      n[        U5      S:w  a  Sn[        U5      eUS   $ )z6Evaluate `expr` and ensure it has a **single** output.   z4multi-output expressions not allowed in this contextr   )_evaluate_exprlenr-   )r`   exprresultmsgs       ra   _evaluate_single_output_expr+EagerDataFrame._evaluate_single_output_expr\  s:    
 $$T*v;!HC,S11ayre   c                V   ^  [        [        R                  " U 4S jU 5       5      5      $ )Nc              3  F   >#    U  H  nTR                  U5      v   M     g 7fr]   )r  ).0r  r`   s     ra   	<genexpr>1EagerDataFrame._evaluate_exprs.<locals>.<genexpr>k  s     (Uut)<)<T)B)Bus   !)tupler   from_iterabler   s   ` ra   _evaluate_exprsEagerDataFrame._evaluate_exprsg  s!     U(((Uu(UUVVre   c                   UR                  U 5      nU" U 5      n[        U5      U Vs/ s H  oDR                  PM     sn=n:w  a  SU SU 3n[        U5      eU$ s  snf )a^  Return list of raw columns.

For eager backends we alias operations at each step.

As a safety precaution, here we can check that the expected result names match those
we were expecting from the various `evaluate_output_names` / `alias_output_names` calls.

Note that for PySpark / DuckDB, we are less free to liberally set aliases whenever we want.
z"Safety assertion failed, expected z, got )_evaluate_aliaseslistr   AssertionError)r`   r  aliasesr  sresult_aliasesr  s          ra   r  EagerDataFrame._evaluate_exprm  sl     ((.d=/56v!vvv66N
 7wivnEUVC %%	 7s   Ac                   g)z@Extract native Series, broadcasting to `len(self)` if necessary.Nr^   )r`   r   s     ra   _extract_comparand!EagerDataFrame._extract_comparand  r   re   c               d    [        U=(       d    S [        U R                  S   5       5       5      $ )Nc              3  ,   #    U  H
  nS U 3v   M     g7f)column_Nr^   )r  xs     ra   r  5EagerDataFrame._numpy_column_names.<locals>.<genexpr>  s     L7K!'!7Ks   r  )r  ranger  )rv   r|   s     ra   _numpy_column_names"EagerDataFrame._numpy_column_names  s'     GLLuTZZ]7KLMMre   c                    g r]   r^   r`   rC  s     ra   _gatherEagerDataFrame._gather  r   re   c                    g r]   r^   r  s     ra   _gather_sliceEagerDataFrame._gather_slice  r   re   c                    g r]   r^   r   s     ra   _select_multi_index"EagerDataFrame._select_multi_index  r   re   c                    g r]   r^   r   s     ra   _select_multi_name!EagerDataFrame._select_multi_name  r   re   c                    g r]   r^   r   s     ra   _select_slice_index"EagerDataFrame._select_slice_index  s    re   c                    g r]   r^   r   s     ra   _select_slice_name!EagerDataFrame._select_slice_name  s    sre   c           	     &   Uu  p#U n[        U5      (       Gd  [        U[        5      (       a  [        U5      S:X  a  UR	                  5       $ [        U5      (       a+  UR                  " S [        UR                  USS9 5       6 nGO)[        U5      (       ap  [        U5      (       d  [        U5      (       a  UR                  U5      nO[        U5      (       a  U R                  UR                  5      nOUR                  U5      nO[        U[         5      (       a/  ["        (       a  UR%                  U5      nOwUR%                  U5      nOe[        U5      (       a  U R'                  UR                  5      nO9[)        U5      (       a  U R'                  U5      nO["        (       a  O[+        U5        [        U5      (       d  [        U[,        5      (       a  UR/                  U/5      nU$ [        U[         [0        45      (       a  UR3                  U5      nU$ [        U5      (       a  UR/                  UR                  5      nU$ [5        U5      (       a2  ["        (       a  UR/                  U5      nU$ UR/                  U5      n U$ [+        U5        U$ )Nr   c              3  <   #    U  H  u  pU(       d  M  Uv   M     g 7fr]   r^   )r  colr   s      ra   r  -EagerDataFrame.__getitem__.<locals>.<genexpr>  s      +XKC! +Xs   	F)r   )r,   
isinstancer   r  r   r%   r   zipr|   r'   r+   r(   r  r&   r  r   slicerN   r  r  r)   r    r   r  r  r  r*   )r`   r  rC  r|   	compliants        ra   r  EagerDataFrame.__getitem__  s1    	W%%'5))c'la.? ''))"7++%33+.y/@/@'RW+X	 #7++!'**hw.?.? ) = =g FI(11 $ 8 8 HI ) = =g FIGU++4 ) < <W EI ) < <W EI$W-- 33GNNC	!'** 33G<	W%T""$$$%--tf5	  D5%.11%33D9	  %T**%--dkk:	  /t444 ) 1 1$ 7I 	 !* 1 1$ 7I  T"re   c                $    U R                  U5      $ r]   )rh  ra  s     ra   r  EagerDataFrame.sink_parquet  s    !!$''re   r^   N)r   ztuple[int, ...])r   zOEagerNamespace[Self, EagerSeriesT, EagerExprT, NativeDataFrameT, NativeSeriesT])r   DataFrame[NativeDataFrameT])r   r   r   r2   )rk   r   r  r   r   r2   )r   r   r   zColumnNotFoundError | None)r  r   r   r   )r   r   r   Sequence[EagerSeriesT])r  r   r   r  )r   r   r   r
   )rv   rJ   r|   r   r   z	list[str])rC  &SizedMultiIndexSelector[NativeSeriesT]r   r2   )rC  _SliceIndex | ranger   r2   )r|   r  r   r2   )r|   z%SizedMultiNameSelector[NativeSeriesT]r   r2   )r|   r  r   r2   )r|   rL   r   r2   )r  z]tuple[SingleIndexSelector | MultiIndexSelector[EagerSeriesT], MultiColSelector[EagerSeriesT]]r   r2   rp  )r   r   r   r   r   r  rg   r  ry  rl   r  r  r  r  r  staticmethodr  r  r  r  r  r  r  r  r  r   r^   re   ra   rR   rR   6  s     7 7
;# FJ">B	C	W& NN!5N	N N
 QC=	<	 MB;
; 
;z(re   rR   r  )p
__future__r   collections.abcr   r   r   r   	itertoolsr   typingr	   r
   r   r   r   r   r   narwhals._compliant.typingr   r   r   r   r   r   r   r   r   r   narwhals._translater   r   r   r   r   r   narwhals._typing_compatr    narwhals._utilsr!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   narwhals.exceptionsr-   ior.   pathlibr/   typesr0   r1   pandaspdpolarsplpyarrowpatyping_extensionsr2   narwhals._compliant.group_byr3   r4   narwhals._compliant.namespacer5   narwhals._spark_like.utilsr6   r7   narwhals._typingr8   r9   r:   r;   narwhals.dataframer<   narwhals.dtypesr=   r>   narwhals.typingr?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   r   rN   __all__rS   rU   rV   rP   r   rO   rQ   rR   r^   re   ra   <module>r     s   " > >  R R R    1    ;  &O<72D?,%7   "  J	e 
ZCLI I(SN- }~"M>AB	SNlkE+,/c1BBC12	(*:NJK46FVWkE\D(*:NJK"$4nDED(\(j"24QQ z<1NNO\:'7FG\(re   