L i5 ddlmZddlmZmZmZmZmZddlm Z m Z m Z m Z m Z ddlmZddlmZmZmZmZmZmZddlmZmZmZmZddlmZmZddlm Z m!Z!m"Z"m#Z#m$Z$ermdd l%m&Z&m'Z'm(Z(dd l)m*Z*dd l+Z,dd l-Z.dd l/Z0dd l1m2Z2m3Z3m4Z4dd l5m6Z6ddl7m8Z8ddlm9Z9m:Z:m;Z;ddlm?Z?ddl@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHGdde4eedfZIedddZJgdZKGddedeeeedeeeZLGddeLeeeZMGd d!e ee!eeeefZNGd"d#eNeefeeefZOGd$d%eNeefe eeeefZPGd&d'eNeefe eeeefZQGd(d)eNeefe eeeefZRGd*d+eNeefe eeeefZSGd,d-eNeefe eeeefZTGd.d/eeeJfZUy )0) annotations) TYPE_CHECKINGAnyGenericLiteralProtocol) CatNamespaceDateTimeNamespace ListNamespaceStringNamespaceStructNamespace)CompliantColumn)CompliantSeriesT_coEagerDataFrameAny EagerSeriesTEagerSeriesT_co NativeSeriesTNativeSeriesT_co) FromIterable FromNativeNumpyConvertible ToNarwhals)TypeVar assert_never)_StoresCompliant _StoresNativeis_compliant_seriesis_sized_multi_index_selectorunstable)IterableIteratorSequence) ModuleTypeN) NotRequiredSelf TypedDict)CompliantDataFrame)EagerNamespace)ImplementationVersion_LimitedContext)DType)Series) Into1DArray IntoDTypeMultiIndexSelector PythonLiteralRollingInterpolationMethodSizedMultiIndexSelector_1DArray _SliceIndexc"eZdZUded<ded<y)HistDataz/NotRequired[list[float] | _1DArray | list[Any]] breakpointz2NativeSeriesT | _1DArray | _CountsT_co | list[Any]countN)__name__ __module__ __qualname____annotations__`/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/narwhals/_compliant/series.pyr7r78sCCAAr?r7 _CountsT_co Iterable[Any]T)bound covariant) CompliantSeries EagerSeriesEagerSeriesCatNamespaceEagerSeriesDateTimeNamespaceEagerSeriesHistEagerSeriesListNamespaceEagerSeriesNamespaceEagerSeriesStringNamespaceEagerSeriesStructNamespaceceZdZUded<edGdZdHdZdIdZedJdZ dKdZ dLdZ dMd Z edNd Z edOd ZdPd ZdQd ZdRdZdSdZdTdZedUdZeddd dVdZdWdZdWdZdWdZdWdZdXdZdXdZdTdZdTdZdHdZdTdZdYd Z dZd!Z!dZd"Z"d[d#Z#d\d$Z$dXd%Z%d]d&Z&d^d'Z'd_d(Z(dTd)Z)d`d*Z*dad+Z+dad,Z,d`d-Z-dTd.Z.dTd/Z/ dbd0Z0 dcd1Z1ddd2Z2d\d3Z3d_d4Z4ded5Z5dfd6Z6dad7Z7d\d8Z8dgd9Z9 dhd:Z:did;Z;djd<ZZ>d?d@dmdAZ? dndBZ@dfdCZAdodDZBeC dpdEZDeC dqdFZEy)rrEr)_implementationcyNr>selfs r@nativezCompliantSeries.nativeWs'*r?c|SrQr>rRs r@__narwhals_series__z#CompliantSeries.__narwhals_series__Ys r?cyrQr>rRs r@__native_namespace__z$CompliantSeries.__native_namespace__\r?cyrQr>clsdatacontexts r@ from_nativezCompliantSeries.from_native]sWZr?c<|jj|dS)Nfull)level)_versionseriesrRs r@ to_narwhalszCompliantSeries.to_narwhals_s}}##D#77r?cyrQr>rSrds r@ _with_nativezCompliantSeries._with_nativebrYr?cyrQr>)rSversions r@ _with_versionzCompliantSeries._with_versioncrYr?cyrQr>rRs r@dtypezCompliantSeries.dtypefs!r?cyrQr>rRs r@namezCompliantSeries.namehsr?cyrQr>)rSrmcopys r@ __array__zCompliantSeries.__array__jrYr?cyrQr>rSothers r@ __contains__zCompliantSeries.__contains__krYr?cyrQr>rSitems r@ __getitem__zCompliantSeries.__getitem__lrYr?cyrQr>rRs r@__iter__zCompliantSeries.__iter__mrYr?c,t|jSrQ)lenrTrRs r@__len__zCompliantSeries.__len__ns4;;r?cyrQr>r[s r@ from_numpyzCompliantSeries.from_numpyqsTWr?N)rormcyrQr>)r\r]r^rorms r@ from_iterablezCompliantSeries.from_iterablessr?cyrQr>rts r@__radd__zCompliantSeries.__radd__}rYr?cyrQr>rts r@__rand__zCompliantSeries.__rand__~rYr?cyrQr>rts r@__rmul__zCompliantSeries.__rmul__rYr?cyrQr>rts r@__ror__zCompliantSeries.__ror__rYr?cyrQr>rRs r@allzCompliantSeries.allrYr?cyrQr>rRs r@anyzCompliantSeries.anyrYr?cyrQr>rRs r@arg_maxzCompliantSeries.arg_maxrYr?cyrQr>rRs r@arg_minzCompliantSeries.arg_minrYr?cyrQr>rRs r@arg_truezCompliantSeries.arg_truerYr?cyrQr>rRs r@r9zCompliantSeries.countrYr?cyrQr>)rS predicates r@filterzCompliantSeries.filterrYr?cyrQr>rRs r@firstzCompliantSeries.firstrYr?cyrQr>rRs r@lastzCompliantSeries.lastrYr?cyrQr>)rSnoffsets r@ gather_everyzCompliantSeries.gather_everyrYr?cyrQr>rSrs r@headzCompliantSeries.headrYr?c(|jdk(SNr)r~rRs r@is_emptyzCompliantSeries.is_emptysxxzQr?cyrQr>)rS descendings r@ is_sortedzCompliantSeries.is_sortedrYr?cyrQr>)rSindexs r@ryzCompliantSeries.itemrYr?cyrQr>rRs r@kurtosiszCompliantSeries.kurtosisrYr?cyrQr>rRs r@r~zCompliantSeries.lenrYr?cyrQr>rRs r@maxzCompliantSeries.maxrYr?cyrQr>rRs r@meanzCompliantSeries.meanrYr?cyrQr>rRs r@medianzCompliantSeries.medianrYr?cyrQr>rRs r@minzCompliantSeries.minrYr?cyrQr>rRs r@n_uniquezCompliantSeries.n_uniquerYr?cyrQr>rRs r@ null_countzCompliantSeries.null_countrYr?cyrQr>)rSquantile interpolations r@rzCompliantSeries.quantilesr?cyrQr>)rSrfractionwith_replacementseeds r@samplezCompliantSeries.samplesr?cyrQr>)rSindicesvaluess r@scatterzCompliantSeries.scatterrYr?cyrQr>rs r@shiftzCompliantSeries.shiftrYr?cyrQr>rRs r@skewzCompliantSeries.skewrYr?cyrQr>)rSr nulls_lasts r@sortzCompliantSeries.sortrYr?cyrQr>rSddofs r@stdzCompliantSeries.stdrYr?cyrQr>rRs r@sumzCompliantSeries.sumrYr?cyrQr>rs r@tailzCompliantSeries.tailrYr?cyrQr>rRs r@to_arrowzCompliantSeries.to_arrowrYr?cyrQr>)rS separator drop_firsts r@ to_dummieszCompliantSeries.to_dummies25r?cyrQr>rRs r@to_framezCompliantSeries.to_framerYr?cyrQr>rRs r@to_listzCompliantSeries.to_listrYr?cyrQr>rRs r@ to_pandaszCompliantSeries.to_pandasrYr?cyrQr>rRs r@ to_polarszCompliantSeries.to_polarsrYr?F)maintain_ordercyrQr>)rSrs r@uniquezCompliantSeries.uniquerYr?cyrQr>)rSrparallelro normalizes r@ value_countszCompliantSeries.value_countsrr?cyrQr>rs r@varzCompliantSeries.varrYr?cyrQr>)rSmaskrus r@zip_withzCompliantSeries.zip_withrYr?cy)z(`Series.hist(bins=..., bin_count=None)`.Nr>)rSbinsinclude_breakpoints r@hist_from_binszCompliantSeries.hist_from_bins r?cy)z(`Series.hist(bins=None, bin_count=...)`.Nr>)rS bin_countrs r@hist_from_bin_countz#CompliantSeries.hist_from_bin_countrr?returnr)rr%)rr#)r]rr^r+rr%)rSeries[NativeSeriesT])rdrrr%)rjr*rr%)rr,)rstr)rmrrqz bool | Nonerr4)rurrbool)ryMultiIndexSelector[Self]rr)rz Iterator[Any])rint)r]r.r^r+rr%) r]rBr^r+rorrmzIntoDType | Nonerr%)rurrr%rr)rrrr%)rr1)rrrrrr%)rrrr%)rrrr)r int | Nonerr)r float | None)rr)rfloat)rrrr2rr) rrrrrrrrrr%)rzint | Sequence[int]rrrr%)rrrrrr%)rrrr)rz pa.Array[Any])rrrrr'CompliantDataFrame[Self, Any, Any, Any])rr)rz list[Any])rzpd.Series[Any])rz pl.Series)rrrr%) rrrrroz str | Nonerrrr)rrrurrr%)r list[float]rrrr)rrrrrr)Fr:r;r<r=propertyrTrVrX classmethodr_rerhrkrmrorrrvrzr|rrrrrrrrrrrrr9rrrrrrrryrr~rrrrrrrrrrrrrrrrrrrrrrrrrrrrr>r?r@rErELsF$# **6ZZ85:!! J3E, WW"& !     0//.!!#1)(<':1+ ""$.H        N('F-',66-16 06G'.)/4B66'+63=6JN6 06.:  8< 0    59 0  r?rE)r4r.rceZdZUded<ded<ded<ded<edd Zedd Zdd Zd d  ddZ ddZ ddZ ddZ d dZ ed!dZed"dZed#dZed$dZed%dZy)&rFr_native_seriesr)rOr*rcr _broadcastc6|jjSrQ)rO_backend_versionrRs r@rzEagerSeries._backend_versions##4466r?cy)aEnsure 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\rds r@_align_full_broadcastz!EagerSeries._align_full_broadcasts r?c@|j|g|j|S)N)ror^)rro)rSvalues r@ _from_scalarzEagerSeries._from_scalars !!5' 4!HHr?F)preserve_broadcastcy)aReturn 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>)rSrdrs r@rhzEagerSeries._with_natives r?cyrQr>rRs r@__narwhals_namespace__z"EagerSeries.__narwhals_namespace__s=@r?cyrQr>rSrowss r@_gatherzEagerSeries._gatherrYr?cyrQr>rs r@ _gather_slicezEagerSeries._gather_slicerYr?ct|ttfr|j|St |r|j |j St|r|j |St|yrQ) isinstanceslicerangerrrrTrrrxs r@rzzEagerSeries.__getitem__s[ dUEN +%%d+ + t $<< , , *4 0<<% %Tr?cyrQr>rRs r@rzEagerSeries.strsFIr?cyrQr>rRs r@dtzEagerSeries.dtsGJr?cyrQr>rRs r@catzEagerSeries.cat sCFr?cyrQr>rRs r@listzEagerSeries.list sEHr?cyrQr>rRs r@structzEagerSeries.struct sILr?Nrztuple[int, ...])rdr%rzSequence[Self])rrrr%)rdrrrrr%)rz2EagerNamespace[Any, Self, Any, Any, NativeSeriesT])rz&SizedMultiIndexSelector[NativeSeriesT]rr%)rz_SliceIndex | rangerr%)ryrrr%)rz/EagerSeriesStringNamespace[Self, NativeSeriesT])rz1EagerSeriesDateTimeNamespace[Self, NativeSeriesT])rz,EagerSeriesCatNamespace[Self, NativeSeriesT])rz-EagerSeriesListNamespace[Self, NativeSeriesT])rz/EagerSeriesStructNamespace[Self, NativeSeriesT])r:r;r<r=rrr rrrhrrrrzrr$r&r(r*r>r?r@rFrFs## 77  "IDI  #  <@    A ;AQCII JJ FF HH LLr?rFczeZdZUded<ed dZed dZed dZed dZeddZ ddZ y )_SeriesNamespacer_compliant_seriesc|jSrQr.rRs r@ compliantz_SeriesNamespace.compliants%%%r?c.|jjSrQ)r1rOrRs r@implementationz_SeriesNamespace.implementations~~---r?c6|jjSrQ)r3rrRs r@backend_versionz _SeriesNamespace.backend_version s""3355r?c.|jjSrQ)r1rcrRs r@rjz_SeriesNamespace.version$s~~&&&r?c.|jjSrQ)r.rTrRs r@rTz_SeriesNamespace.native(s%%,,,r?c8|jj|SrQ)r1rhrgs r@ with_nativez_SeriesNamespace.with_native,s~~**622r?N)rr)rr)r+)rr*)rr)rdrrr) r:r;r<r=rr1r3r5rjrTr9r>r?r@r-r-sq +* &&..66''--3r?r-c eZdZUded<ddZy)rKrr.c||_yrQr0rgs r@__init__zEagerSeriesNamespace.__init__6s !'r?N)rdrrNone)r:r;r<r=r<r>r?r@rKrK0s'&(r?rKc eZdZy)rGNr:r;r<r>r?r@rGrG:r?rGc eZdZy)rHNr?r>r?r@rHrHAr@r?rHc eZdZy)rJNr?r>r?r@rJrJHr@r?rJc eZdZy)rLNr?r>r?r@rLrLOr@r?rLc eZdZy)rMNr?r>r?r@rMrMVr@r?rMceZdZUded<ded<ded<eddZe ddZdd Zd d  dd Z dd Z ddZ ddZ ddZ ddZddZd dZ d!dZy)"rIEagerSeries[NativeSeriesT]_seriesr _breakpoint$HistData[NativeSeriesT, _CountsT_co]_datac.|jjSrQ)rGrTrRs r@rTzEagerSeriesHist.nativebs||"""r?cD|j|}||_||_|SrQ)__new__rGrH)r\rdrobjs r@ from_serieszEagerSeriesHist.from_seriesfs%kk# , r?cyrQr>rRs r@rzEagerSeriesHist.to_frameorYr?both)closedcyrQr>)rSstartend num_samplesrRs r@ _linear_spacezEagerSeriesHist._linear_spacepsr?cyrQr>rRs r@is_empty_serieszEagerSeriesHist.is_empty_serieszrYr?c,|jrggdSdgiS)N)r8r9r9)rHrRs r@ data_emptyzEagerSeriesHist.data_empty}s262B2Bb2.URT Ur?cyrQr>)rSargs r@ series_emptyzEagerSeriesHist.series_empty/2r?ct|dkr|j|_|S|jr|j ||_|S|j ||_|S)N)r~r[rJrYr^_calculate_histrSrs r@ with_binszEagerSeriesHist.with_binssb t9>*DJ   ! ! #**40DJ --d3DJ r?c|dk(r|j|_|S|jr|j||_|S|j |j ||_|Sr)r[rJrYr^rb_calculate_binsrSrs r@with_bin_countzEagerSeriesHist.with_bin_countsi >*DJ   ! ! #**95DJ --d.B.B9.MNDJ r?c\t|tr|jdd|dzn|}|ddS)Nrra)rrrW)rSr]rs r@_calculate_breakpointz%EagerSeriesHist._calculate_breakpoints04>sC4Ht!!!Qa0cABxr?cyrQr>rgs r@rfzEagerSeriesHist._calculate_binsrYr?cyrQr>rcs r@rbzEagerSeriesHist._calculate_histr_r?Nr)rdrFrrrr%)rr) rTrrUrrVrrRzLiteral['both', 'none']rr4r)rrI)r]int | list[float]rrI)rrrr%)rrrr%)r]rmrlist[float] | _1DArray)rrrr4)rrnrrI)r:r;r<r=rrTr rOrrWrYr[r^rdrhrjrfrbr>r?r@rIrI]s '' // ##/HL 1+1   (  +V 3$3 -3?3*3 -3r?rI)V __future__rtypingrrrrr!narwhals._compliant.any_namespacer r r r r narwhals._compliant.columnrnarwhals._compliant.typingrrrrrrnarwhals._translaterrrrnarwhals._typing_compatrrnarwhals._utilsrrrrrcollections.abcr r!r"typesr#pandaspdpolarsplpyarrowpatyping_extensionsr$r%r&narwhals._compliant.dataframer'narwhals._compliant.namespacer(r)r*r+narwhals.dtypesr,narwhals.seriesr-narwhals.typingr.r/r0r1r2r3r4r5r7rA__all__rErFr-rKrGrHrJrLrMrIr>r?r@rsM"AA7WV9<< >>@<HH%&   B9gm]&BCB m?dK  { ./}&' ] { |DM/-0(=2IDMN3()"# "2 233>(_&667 O- -.(_&667! _. ./_&667o& _. ./\#334, \+ +,\#334L! \+ +,_&667O$ _. ./B3h}k9:B3r?