
    ei5                       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__     \/var/www/html/glpi_dashboard/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__\       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   rd   s     r@   _with_nativezCompliantSeries._with_nativeb   rY   r?   c                     y rQ   r>   )rS   versions     r@   _with_versionzCompliantSeries._with_versionc   rY   r?   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   rY   r?   c                     y rQ   r>   rS   others     r@   __contains__zCompliantSeries.__contains__k   rY   r?   c                     y rQ   r>   rS   items     r@   __getitem__zCompliantSeries.__getitem__l   rY   r?   c                     y rQ   r>   rR   s    r@   __iter__zCompliantSeries.__iter__m   rY   r?   c                ,    t        | j                        S rQ   )lenrT   rR   s    r@   __len__zCompliantSeries.__len__n   s    4;;r?   c                   y rQ   r>   r[   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__}   rY   r?   c                     y rQ   r>   rt   s     r@   __rand__zCompliantSeries.__rand__~   rY   r?   c                     y rQ   r>   rt   s     r@   __rmul__zCompliantSeries.__rmul__   rY   r?   c                     y rQ   r>   rt   s     r@   __ror__zCompliantSeries.__ror__   rY   r?   c                     y rQ   r>   rR   s    r@   allzCompliantSeries.all   rY   r?   c                     y rQ   r>   rR   s    r@   anyzCompliantSeries.any   rY   r?   c                    y rQ   r>   )rS   ignore_nullss     r@   	any_valuezCompliantSeries.any_value   rY   r?   c                     y rQ   r>   rR   s    r@   arg_maxzCompliantSeries.arg_max   rY   r?   c                     y rQ   r>   rR   s    r@   arg_minzCompliantSeries.arg_min   rY   r?   c                     y rQ   r>   rR   s    r@   arg_truezCompliantSeries.arg_true   rY   r?   c                     y rQ   r>   rR   s    r@   r9   zCompliantSeries.count   rY   r?   c                     y rQ   r>   )rS   	predicates     r@   filterzCompliantSeries.filter   rY   r?   c                     y rQ   r>   rR   s    r@   firstzCompliantSeries.first   rY   r?   c                     y rQ   r>   rR   s    r@   lastzCompliantSeries.last   rY   r?   c                     y rQ   r>   )rS   noffsets      r@   gather_everyzCompliantSeries.gather_every   rY   r?   c                     y rQ   r>   rS   r   s     r@   headzCompliantSeries.head   rY   r?   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   rY   r?   c                     y rQ   r>   )rS   indexs     r@   ry   zCompliantSeries.item   rY   r?   c                     y rQ   r>   rR   s    r@   kurtosiszCompliantSeries.kurtosis   rY   r?   c                     y rQ   r>   rR   s    r@   r~   zCompliantSeries.len   rY   r?   c                     y rQ   r>   rR   s    r@   maxzCompliantSeries.max   rY   r?   c                     y rQ   r>   rR   s    r@   meanzCompliantSeries.mean   rY   r?   c                     y rQ   r>   rR   s    r@   medianzCompliantSeries.median   rY   r?   c                     y rQ   r>   rR   s    r@   minzCompliantSeries.min   rY   r?   c                     y rQ   r>   rR   s    r@   n_uniquezCompliantSeries.n_unique   rY   r?   c                     y rQ   r>   rR   s    r@   
null_countzCompliantSeries.null_count   rY   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   rY   r?   c                     y rQ   r>   r   s     r@   shiftzCompliantSeries.shift   rY   r?   c                     y rQ   r>   rR   s    r@   skewzCompliantSeries.skew   rY   r?   c                    y rQ   r>   )rS   r   
nulls_lasts      r@   sortzCompliantSeries.sort   rY   r?   c                    y rQ   r>   rS   ddofs     r@   stdzCompliantSeries.std   rY   r?   c                     y rQ   r>   rR   s    r@   sumzCompliantSeries.sum   rY   r?   c                     y rQ   r>   r   s     r@   tailzCompliantSeries.tail   rY   r?   c                     y rQ   r>   rR   s    r@   to_arrowzCompliantSeries.to_arrow   rY   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   rY   r?   c                     y rQ   r>   rR   s    r@   to_listzCompliantSeries.to_list   rY   r?   c                     y rQ   r>   rR   s    r@   	to_pandaszCompliantSeries.to_pandas   rY   r?   c                     y rQ   r>   rR   s    r@   	to_polarszCompliantSeries.to_polars   rY   r?   F)maintain_orderc                    y rQ   r>   )rS   r   s     r@   uniquezCompliantSeries.unique   rY   r?   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   rY   r?   c                     y rQ   r>   )rS   maskru   s      r@   zip_withzCompliantSeries.zip_with   rY   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])rd   r   r   r%   )rj   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_   re   rh   rk   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*   rc   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\   rd   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   rd   r  s      r@   rh   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   rY   r?   c                     y rQ   r>   r  s     r@   _gather_slicezEagerSeries._gather_slice   rY   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, ...])rd   r%   r   zSequence[Self])r  r   r   r%   )rd   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  rh   r  r  r   rz   r  r'  r)  r+  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   r1  rR   s    r@   	compliantz_SeriesNamespace.compliant  s    %%%r?   c                .    | j                   j                  S rQ   )r4  rO   rR   s    r@   implementationz_SeriesNamespace.implementation  s    ~~---r?   c                6    | j                   j                         S rQ   )r6  r  rR   s    r@   backend_versionz _SeriesNamespace.backend_version!  s    ""3355r?   c                .    | j                   j                  S rQ   )r4  rc   rR   s    r@   rj   z_SeriesNamespace.version%  s    ~~&&&r?   c                .    | j                   j                  S rQ   )r1  rT   rR   s    r@   rT   z_SeriesNamespace.native)  s    %%,,,r?   c               8    | j                   j                  |      S rQ   )r4  rh   rg   s     r@   with_nativez_SeriesNamespace.with_native-  s    ~~**622r?   N)r   r   )r   r)   r.  )r   r*   )r   r   )rd   r   r   r   )r:   r;   r<   r=   r  r4  r6  r8  rj   rT   r<  r>   r?   r@   r0  r0    sq    
 +*& & . . 6 6 ' ' - -3r?   r0  c                       e Zd ZU ded<   ddZy)rK   r   r1  c                   || _         y rQ   r3  rg   s     r@   __init__zEagerSeriesNamespace.__init__7  s
    !'r?   N)rd   r   r   None)r:   r;   r<   r=   r?  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   NrB  r>   r?   r@   rH   rH   B  rC  r?   rH   c                      e Zd Zy)rJ   NrB  r>   r?   r@   rJ   rJ   I  rC  r?   rJ   c                      e Zd Zy)rL   NrB  r>   r?   r@   rL   rL   P  rC  r?   rL   c                      e Zd Zy)rM   NrB  r>   r?   r@   rM   rM   W  rC  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   )rJ  rT   rR   s    r@   rT   zEagerSeriesHist.nativec  s    ||"""r?   c               D    | j                  |       }||_        ||_        |S rQ   )__new__rJ  rK  )r\   rd   r   objs       r@   from_serieszEagerSeriesHist.from_seriesg  s%     kk#,
r?   c                     y rQ   r>   rR   s    r@   r   zEagerSeriesHist.to_framep  rY   r?   both)closedc                    y rQ   r>   )rS   startendnum_samplesrU  s        r@   _linear_spacezEagerSeriesHist._linear_spaceq  s     r?   c                     y rQ   r>   rR   s    r@   is_empty_serieszEagerSeriesHist.is_empty_series{  rY   r?   c                ,    | j                   rg g dS dg iS )N)r8   r9   r9   )rK  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~   r^  rM  r\  ra  _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   )r^  rM  r\  ra  re  _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   rd  )r"  r  rZ  )rS   r`  r   s      r@   _calculate_breakpointz%EagerSeriesHist._calculate_breakpoint  s0    4>sC4Ht!!!Qa0cABxr?   c                     y rQ   r>   rj  s     r@   ri  zEagerSeriesHist._calculate_bins  rY   r?   c                     y rQ   r>   rf  s     r@   re  zEagerSeriesHist._calculate_hist  rb  r?   Nr   )rd   rI  r   r  r   r%   )r   r   )
rW  r  rX  r  rY  r  rU  zLiteral['both', 'none']r   r4   r  )r   rL  )r`  int | list[float]r   rL  )r   r
  r   r%   )r   r  r   r%   )r`  rp  r   list[float] | _1DArray)r   r  r   r4   )r   rq  r   rL  )r:   r;   r<   r=   r  rT   r  rR  r   rZ  r\  r^  ra  rg  rk  rm  ri  re  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   r0  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?   