
    [i5                       d dl mZ d dlmZmZmZmZmZ d dlm	Z	m
Z
mZmZmZ d dlmZ d dlmZmZmZmZmZmZ d dlmZmZmZmZ d dlmZmZ d dlm Z m!Z!m"Z"m#Z#m$Z$ ermd d	l%m&Z&m'Z'm(Z( d d
l)m*Z* d dl+Z,d dl-Z.d dl/Z0d dl1m2Z2m3Z3m4Z4 d dl5m6Z6 d dl7m8Z8 d dlm9Z9m:Z:m;Z; d dl<m=Z= d dl>m?Z? d dl@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZH  G d de4eedf         ZI eddd      ZJg dZK G d ded   eee   ed   eee         ZL G d deLe   ee         ZM G d  d!e e   e!e   eeef         ZN G d" d#eNeef   eeef         ZO G d$ d%eNeef   e	e   eeef         ZP G d& d'eNeef   e
e   eeef         ZQ G d( d)eNeef   ee   eeef         ZR G d* d+eNeef   ee   eeef         ZS G d, d-eNeef   ee   eeef         ZT G d. d/eeeJf         ZUy)0    )annotations)TYPE_CHECKINGAnyGenericLiteralProtocol)CatNamespaceDateTimeNamespaceListNamespaceStringNamespaceStructNamespace)CompliantColumn)CompliantSeriesT_coEagerDataFrameAnyEagerSeriesTEagerSeriesT_coNativeSeriesTNativeSeriesT_co)FromIterable
FromNativeNumpyConvertible
ToNarwhals)TypeVarassert_never)_StoresCompliant_StoresNativeis_compliant_seriesis_sized_multi_index_selectorunstable)IterableIteratorSequence)
ModuleTypeN)NotRequiredSelf	TypedDict)CompliantDataFrame)EagerNamespace)ImplementationVersion_LimitedContext)DType)Series)Into1DArray	IntoDTypeMultiIndexSelectorPythonLiteralRollingInterpolationMethodSizedMultiIndexSelector_1DArray_SliceIndexc                  "    e Zd ZU ded<   ded<   y)HistDataz/NotRequired[list[float] | _1DArray | list[Any]]
breakpointz2NativeSeriesT | _1DArray | _CountsT_co | list[Any]countN)__name__
__module____qualname____annotations__     k/var/www/html/userprofiledev.eatanceapp.com/venv/lib/python3.12/site-packages/narwhals/_compliant/series.pyr7   r7   8   s    CCAAr?   r7   _CountsT_coIterable[Any]T)bound	covariant)	CompliantSeriesEagerSeriesEagerSeriesCatNamespaceEagerSeriesDateTimeNamespaceEagerSeriesHistEagerSeriesListNamespaceEagerSeriesNamespaceEagerSeriesStringNamespaceEagerSeriesStructNamespacec                     e Zd ZU ded<   edHd       ZdIdZdJdZedKd       Z	dLdZ
dMdZdNd	ZedOd
       ZedPd       ZdQdZdRdZdSdZdTdZdUdZedVd       Zeddd	 	 	 	 	 	 	 	 	 dWd       ZdXdZdXdZdXdZdXdZdYdZdYdZdZdZdUdZdUdZdIdZdUd Z d[d!Z!d\d"Z"d\d#Z#d]d$Z$d^d%Z%dYd&Z&d_d'Z'd`d(Z(dad)Z)dUd*Z*dbd+Z+dcd,Z,dcd-Z-dbd.Z.dUd/Z/dUd0Z0	 	 	 	 	 	 ddd1Z1	 	 	 	 	 	 	 	 	 	 ded2Z2dfd3Z3d^d4Z4dad5Z5dgd6Z6dhd7Z7dcd8Z8d^d9Z9did:Z:	 	 	 	 	 	 djd;Z;dkd<Z<dld=Z=dmd>Z>dnd?Z?d@dAdodBZ@	 	 	 	 	 	 	 	 	 	 dpdCZAdhdDZBdqdEZCeD	 	 	 	 	 	 drdF       ZEeD	 	 	 	 	 	 dsdG       ZFy)trE   r)   _implementationc                     y Nr>   selfs    r@   nativezCompliantSeries.nativeW   s    '*r?   c                    | S rQ   r>   rR   s    r@   __narwhals_series__z#CompliantSeries.__narwhals_series__Y   s    r?   c                     y rQ   r>   rR   s    r@   __native_namespace__z$CompliantSeries.__native_namespace__\   s    #r?   c                   y rQ   r>   clsdatacontexts      r@   from_nativezCompliantSeries.from_native]   s    WZr?   c                <    | j                   j                  | d      S )Nfull)level)_versionseriesrR   s    r@   to_narwhalszCompliantSeries.to_narwhals_   s    }}##D#77r?   c                     y rQ   r>   rS   rc   s     r@   _with_nativezCompliantSeries._with_nativeb   s    r?   c                     y rQ   r>   )rS   versions     r@   _with_versionzCompliantSeries._with_versionc       sr?   c                     y rQ   r>   rR   s    r@   dtypezCompliantSeries.dtypef   s    !r?   c                     y rQ   r>   rR   s    r@   namezCompliantSeries.nameh   s    r?   c                    y rQ   r>   )rS   rm   copys      r@   	__array__zCompliantSeries.__array__j   s    sr?   c                     y rQ   r>   rS   others     r@   __contains__zCompliantSeries.__contains__k   s    r?   c                     y rQ   r>   rS   items     r@   __getitem__zCompliantSeries.__getitem__l   s    #r?   c                     y rQ   r>   rR   s    r@   __iter__zCompliantSeries.__iter__m       r?   c                ,    t        | j                        S rQ   )lenrT   rR   s    r@   __len__zCompliantSeries.__len__n   s    4;;r?   c                   y rQ   r>   rZ   s      r@   
from_numpyzCompliantSeries.from_numpyq   s    TWr?    N)ro   rm   c                   y rQ   r>   )r[   r\   r]   ro   rm   s        r@   from_iterablezCompliantSeries.from_iterables   s     r?   c                     y rQ   r>   rt   s     r@   __radd__zCompliantSeries.__radd__}       Cr?   c                     y rQ   r>   rt   s     r@   __rand__zCompliantSeries.__rand__~   r   r?   c                     y rQ   r>   rt   s     r@   __rmul__zCompliantSeries.__rmul__   r   r?   c                     y rQ   r>   rt   s     r@   __ror__zCompliantSeries.__ror__       3r?   c                     y rQ   r>   rR   s    r@   allzCompliantSeries.all       3r?   c                     y rQ   r>   rR   s    r@   anyzCompliantSeries.any   r   r?   c                    y rQ   r>   )rS   ignore_nullss     r@   	any_valuezCompliantSeries.any_value   s    r?   c                     y rQ   r>   rR   s    r@   arg_maxzCompliantSeries.arg_max       cr?   c                     y rQ   r>   rR   s    r@   arg_minzCompliantSeries.arg_min   r   r?   c                     y rQ   r>   rR   s    r@   arg_truezCompliantSeries.arg_true   s    r?   c                     y rQ   r>   rR   s    r@   r9   zCompliantSeries.count       Cr?   c                     y rQ   r>   )rS   	predicates     r@   filterzCompliantSeries.filter       cr?   c                     y rQ   r>   rR   s    r@   firstzCompliantSeries.first       cr?   c                     y rQ   r>   rR   s    r@   lastzCompliantSeries.last       Sr?   c                     y rQ   r>   )rS   noffsets      r@   gather_everyzCompliantSeries.gather_every   s    r?   c                     y rQ   r>   rS   r   s     r@   headzCompliantSeries.head       Cr?   c                (    | j                         dk(  S Nr   )r   rR   s    r@   is_emptyzCompliantSeries.is_empty   s    xxzQr?   c                    y rQ   r>   )rS   
descendings     r@   	is_sortedzCompliantSeries.is_sorted   s    cr?   c                     y rQ   r>   )rS   indexs     r@   ry   zCompliantSeries.item   r   r?   c                     y rQ   r>   rR   s    r@   kurtosiszCompliantSeries.kurtosis   s    r?   c                     y rQ   r>   rR   s    r@   r   zCompliantSeries.len       #r?   c                     y rQ   r>   rR   s    r@   maxzCompliantSeries.max   r   r?   c                     y rQ   r>   rR   s    r@   meanzCompliantSeries.mean   s    Sr?   c                     y rQ   r>   rR   s    r@   medianzCompliantSeries.median       sr?   c                     y rQ   r>   rR   s    r@   minzCompliantSeries.min   r   r?   c                     y rQ   r>   rR   s    r@   n_uniquezCompliantSeries.n_unique   r   r?   c                     y rQ   r>   rR   s    r@   
null_countzCompliantSeries.null_count   s    r?   c                     y rQ   r>   )rS   quantileinterpolations      r@   r   zCompliantSeries.quantile   s    r?   c                    y rQ   r>   )rS   r   fractionwith_replacementseeds        r@   samplezCompliantSeries.sample   s     r?   c                     y rQ   r>   )rS   indicesvaluess      r@   scatterzCompliantSeries.scatter   s    #r?   c                     y rQ   r>   r   s     r@   shiftzCompliantSeries.shift   r   r?   c                     y rQ   r>   rR   s    r@   skewzCompliantSeries.skew   r   r?   c                    y rQ   r>   )rS   r   
nulls_lasts      r@   sortzCompliantSeries.sort       3r?   c                    y rQ   r>   rS   ddofs     r@   stdzCompliantSeries.std       #r?   c                     y rQ   r>   rR   s    r@   sumzCompliantSeries.sum   r   r?   c                     y rQ   r>   r   s     r@   tailzCompliantSeries.tail   r   r?   c                     y rQ   r>   rR   s    r@   to_arrowzCompliantSeries.to_arrow   r}   r?   c                    y rQ   r>   )rS   	separator
drop_firsts      r@   
to_dummieszCompliantSeries.to_dummies       25r?   c                     y rQ   r>   rR   s    r@   to_framezCompliantSeries.to_frame   r   r?   c                     y rQ   r>   rR   s    r@   to_listzCompliantSeries.to_list   r   r?   c                     y rQ   r>   rR   s    r@   	to_pandaszCompliantSeries.to_pandas   r   r?   c                     y rQ   r>   rR   s    r@   	to_polarszCompliantSeries.to_polars   r   r?   F)maintain_orderc                    y rQ   r>   )rS   r   s     r@   uniquezCompliantSeries.unique   s    sr?   c                    y rQ   r>   )rS   r   parallelro   	normalizes        r@   value_countszCompliantSeries.value_counts   r   r?   c                    y rQ   r>   r   s     r@   varzCompliantSeries.var   r   r?   c                     y rQ   r>   )rS   maskru   s      r@   zip_withzCompliantSeries.zip_with   rk   r?   c                    y)z(`Series.hist(bins=..., bin_count=None)`.Nr>   )rS   binsinclude_breakpoints      r@   hist_from_binszCompliantSeries.hist_from_bins       
 	r?   c                    y)z(`Series.hist(bins=None, bin_count=...)`.Nr>   )rS   	bin_countr  s      r@   hist_from_bin_countz#CompliantSeries.hist_from_bin_count   r  r?   returnr   )r  r%   )r  r#   )r\   r   r]   r+   r  r%   )r  Series[NativeSeriesT])rc   r   r  r%   )ri   r*   r  r%   )r  r,   )r  str)rm   r   rq   zbool | Noner  r4   )ru   r   r  bool)ry   MultiIndexSelector[Self]r  r   )r  zIterator[Any])r  int)r\   r.   r]   r+   r  r%   )
r\   rB   r]   r+   ro   r  rm   zIntoDType | Noner  r%   )ru   r   r  r%   r  r  )r   r  r  r1   )r   r   r  r%   )r  r1   )r   r  r   r  r  r%   )r   r  r  r%   )r   r  r  r  )r   
int | Noner  r   )r  float | None)r  r   )r  float)r   r  r   r2   r  r  )
r   r  r   r  r   r  r   r  r  r%   )r   zint | Sequence[int]r   r   r  r%   )r   r  r   r  r  r%   )r   r  r  r  )r  zpa.Array[Any])r   r  r   r  r  'CompliantDataFrame[Self, Any, Any, Any])r  r  )r  z	list[Any])r  zpd.Series[Any])r  z	pl.Series)r   r  r  r%   )
r   r  r   r  ro   z
str | Noner   r  r  r  )r  r   ru   r   r  r%   )r  list[float]r  r  r  r  )r
  r  r  r  r  r  )Gr:   r;   r<   r=   propertyrT   rV   rX   classmethodr^   rd   rg   rj   rm   ro   rr   rv   rz   r|   r   r   r   r   r   r   r   r   r   r   r   r   r   r9   r   r   r   r   r   r   r   ry   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r   r  r  r>   r?   r@   rE   rE   L   sI    $#* * 6Z Z8 5: ! ! J3E,  W W "&
 !    
  0//.D!!#1)(<' :1+ ""$.H	 	
   
 N('F-',66-16	06 G'.)/4B66'+63=6JN6	06 .: 8<	0  59	0 r?   rE   )r4   r.   r  c                      e Zd ZU ded<   ded<   ded<   ded<   edd	       Zedd
       ZddZdd	 	 	 	 	 ddZ		 	 ddZ
ddZddZd dZed!d       Zed"d       Zed#d       Zed$d       Zed%d       Zy)&rF   r   _native_seriesr)   rO   r*   rb   r  
_broadcastc                6    | j                   j                         S rQ   )rO   _backend_versionrR   s    r@   r  zEagerSeries._backend_version   s    ##4466r?   c                     y)a  Ensure all of `series` have the same length (and index if `pandas`).

        Scalars get broadcasted to the full length of the longest Series.

        This is useful when you need to construct a full Series anyway, such as:

            DataFrame.select(...)

        It should not be used in binary operations, such as:

            nw.col("a") - nw.col("a").mean()

        because then it's more efficient to extract the right-hand-side's single element as a scalar.
        Nr>   )r[   rc   s     r@   _align_full_broadcastz!EagerSeries._align_full_broadcast   s      	r?   c                @    | j                  |g| j                  |       S )N)ro   r]   )r   ro   )rS   values     r@   _from_scalarzEagerSeries._from_scalar   s     !!5'		4!HHr?   F)preserve_broadcastc                    y)a  Return a new `CompliantSeries`, wrapping the native `series`.

        In cases when operations are known to not affect whether a result should
        be broadcast, we can pass `preserve_broadcast=True`.
        Set this with care - it should only be set for unary expressions which don't
        change length or order, such as `.alias` or `.fill_null`. If in doubt, don't
        set it, you probably don't need it.
        Nr>   )rS   rc   r%  s      r@   rg   zEagerSeries._with_native   s     	r?   c                     y rQ   r>   rR   s    r@   __narwhals_namespace__z"EagerSeries.__narwhals_namespace__   s    =@r?   c                     y rQ   r>   rS   rowss     r@   _gatherzEagerSeries._gather   s    Sr?   c                     y rQ   r>   r*  s     r@   _gather_slicezEagerSeries._gather_slice   s    r?   c                    t        |t        t        f      r| j                  |      S t	        |      r| j                  |j                        S t        |      r| j                  |      S t        |       y rQ   )	
isinstancesliceranger.  r   r,  rT   r   r   rx   s     r@   rz   zEagerSeries.__getitem__   s[    dUEN+%%d++t$<<,,*40<<%%Tr?   c                     y rQ   r>   rR   s    r@   r  zEagerSeries.str  s    FIr?   c                     y rQ   r>   rR   s    r@   dtzEagerSeries.dt  s    GJr?   c                     y rQ   r>   rR   s    r@   catzEagerSeries.cat
  s    CFr?   c                     y rQ   r>   rR   s    r@   listzEagerSeries.list  s    EHr?   c                     y rQ   r>   rR   s    r@   structzEagerSeries.struct  s    ILr?   Nr  ztuple[int, ...])rc   r%   r  zSequence[Self])r#  r   r  r%   )rc   r   r%  r  r  r%   )r  z2EagerNamespace[Any, Self, Any, Any, NativeSeriesT])r+  z&SizedMultiIndexSelector[NativeSeriesT]r  r%   )r+  z_SliceIndex | ranger  r%   )ry   r  r  r%   )r  z/EagerSeriesStringNamespace[Self, NativeSeriesT])r  z1EagerSeriesDateTimeNamespace[Self, NativeSeriesT])r  z,EagerSeriesCatNamespace[Self, NativeSeriesT])r  z-EagerSeriesListNamespace[Self, NativeSeriesT])r  z/EagerSeriesStructNamespace[Self, NativeSeriesT])r:   r;   r<   r=   r  r  r  r!  r$  rg   r(  r,  r.  rz   r  r5  r7  r9  r;  r>   r?   r@   rF   rF      s    ##7 7  "I DI#<@	A	;A QC I IJ JF FH HL Lr?   rF   c                  z    e Zd ZU ded<   ed
d       Zedd       Zedd       Zedd       Zedd       Z	ddZ
y	)_SeriesNamespacer   _compliant_seriesc                    | j                   S rQ   r?  rR   s    r@   	compliantz_SeriesNamespace.compliant  s    %%%r?   c                .    | j                   j                  S rQ   )rB  rO   rR   s    r@   implementationz_SeriesNamespace.implementation  s    ~~---r?   c                6    | j                   j                         S rQ   )rD  r  rR   s    r@   backend_versionz _SeriesNamespace.backend_version!  s    ""3355r?   c                .    | j                   j                  S rQ   )rB  rb   rR   s    r@   ri   z_SeriesNamespace.version%  s    ~~&&&r?   c                .    | j                   j                  S rQ   )r?  rT   rR   s    r@   rT   z_SeriesNamespace.native)  s    %%,,,r?   c               8    | j                   j                  |      S rQ   )rB  rg   rf   s     r@   with_nativez_SeriesNamespace.with_native-  s    ~~**622r?   N)r  r   )r  r)   r<  )r  r*   )r  r   )rc   r   r  r   )r:   r;   r<   r=   r  rB  rD  rF  ri   rT   rJ  r>   r?   r@   r>  r>    sq    
 +*& & . . 6 6 ' ' - -3r?   r>  c                       e Zd ZU ded<   ddZy)rK   r   r?  c                   || _         y rQ   rA  rf   s     r@   __init__zEagerSeriesNamespace.__init__7  s
    !'r?   N)rc   r   r  None)r:   r;   r<   r=   rM  r>   r?   r@   rK   rK   1  s     '&(r?   rK   c                      e Zd Zy)rG   Nr:   r;   r<   r>   r?   r@   rG   rG   ;       r?   rG   c                      e Zd Zy)rH   NrP  r>   r?   r@   rH   rH   B  rQ  r?   rH   c                      e Zd Zy)rJ   NrP  r>   r?   r@   rJ   rJ   I  rQ  r?   rJ   c                      e Zd Zy)rL   NrP  r>   r?   r@   rL   rL   P  rQ  r?   rL   c                      e Zd Zy)rM   NrP  r>   r?   r@   rM   rM   W  rQ  r?   rM   c                      e Zd ZU ded<   ded<   ded<   edd       Ze	 	 	 	 	 	 dd       Zdd	Zd
d	 	 	 	 	 	 	 	 	 ddZ	ddZ
ddZ	 	 	 	 ddZddZddZddZd dZ	 	 	 	 d!dZy)"rI   EagerSeries[NativeSeriesT]_seriesr  _breakpoint$HistData[NativeSeriesT, _CountsT_co]_datac                .    | j                   j                  S rQ   )rX  rT   rR   s    r@   rT   zEagerSeriesHist.nativec  s    ||"""r?   c               D    | j                  |       }||_        ||_        |S rQ   )__new__rX  rY  )r[   rc   r  objs       r@   from_serieszEagerSeriesHist.from_seriesg  s%     kk#,
r?   c                     y rQ   r>   rR   s    r@   r   zEagerSeriesHist.to_framep  s    Sr?   both)closedc                    y rQ   r>   )rS   startendnum_samplesrc  s        r@   _linear_spacezEagerSeriesHist._linear_spaceq  s     r?   c                     y rQ   r>   rR   s    r@   is_empty_serieszEagerSeriesHist.is_empty_series{  s    sr?   c                ,    | j                   rg g dS dg iS )N)r8   r9   r9   )rY  rR   s    r@   
data_emptyzEagerSeriesHist.data_empty~  s    262B2Bb2.URTUr?   c                    y rQ   r>   )rS   args     r@   series_emptyzEagerSeriesHist.series_empty      /2r?   c                   t        |      dk  r| j                         | _        | S | j                         r| j	                  |      | _        | S | j                  |      | _        | S )N   )r   rl  r[  rj  ro  _calculate_histrS   r  s     r@   	with_binszEagerSeriesHist.with_bins  sb    t9>*DJ
 	 !!#**40DJ  --d3DJr?   c                   |dk(  r| j                         | _        | S | j                         r| j                  |      | _        | S | j	                  | j                  |            | _        | S r   )rl  r[  rj  ro  rs  _calculate_binsrS   r
  s     r@   with_bin_countzEagerSeriesHist.with_bin_count  si    >*DJ
 	 !!#**95DJ  --d.B.B9.MNDJr?   c               \    t        |t              r| j                  dd|dz         n|}|dd  S )Nr   rr  )r0  r  rh  )rS   rn  r  s      r@   _calculate_breakpointz%EagerSeriesHist._calculate_breakpoint  s0    4>sC4Ht!!!Qa0cABxr?   c                     y rQ   r>   rx  s     r@   rw  zEagerSeriesHist._calculate_bins  s    3r?   c                     y rQ   r>   rt  s     r@   rs  zEagerSeriesHist._calculate_hist  rp  r?   Nr  )rc   rW  r  r  r  r%   )r  r   )
re  r  rf  r  rg  r  rc  zLiteral['both', 'none']r  r4   r  )r  rZ  )rn  int | list[float]r  rZ  )r  r  r  r%   )r
  r  r  r%   )rn  r~  r  list[float] | _1DArray)r
  r  r  r4   )r  r  r  rZ  )r:   r;   r<   r=   r  rT   r  r`  r   rh  rj  rl  ro  ru  ry  r{  rw  rs  r>   r?   r@   rI   rI   ^  s    ''//# # /HL	  1 +1  	 ( 
 +V
3$3	-3 ?3*3	-3r?   rI   )V
__future__r   typingr   r   r   r   r   !narwhals._compliant.any_namespacer	   r
   r   r   r   narwhals._compliant.columnr   narwhals._compliant.typingr   r   r   r   r   r   narwhals._translater   r   r   r   narwhals._typing_compatr   r   narwhals._utilsr   r   r   r   r   collections.abcr    r!   r"   typesr#   pandaspdpolarsplpyarrowpatyping_extensionsr$   r%   r&   narwhals._compliant.dataframer'   narwhals._compliant.namespacer(   r)   r*   r+   narwhals.dtypesr,   narwhals.seriesr-   narwhals.typingr.   r/   r0   r1   r2   r3   r4   r5   r7   rA   __all__rE   rF   r>  rK   rG   rH   rJ   rL   rM   rI   r>   r?   r@   <module>r     sM   " A A  7  W V 9  << >>@<HH%&	 	 	B9gm]&BC B
 m?dK
|./}&']|~DM/-0(=2I DMN3()"# "2233>(_&667O--.(_&667!_../_&667o&_../\#334,\++,\#334L!\++,_&667O$_../B3h}k9: B3r?   