
    'h<             
      H   S SK Jr  S SKrS SKrS SKrS SKrS SKJrJr  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Jr  S SK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,  S SK-J.r.J/r/J0r0  S SK1J2r2  S SK3J4r4  S SK5J6r6J7r7J8r8J9r9J:r:J;r;J<r<J=r=J>r>  S SK?J@r@JArA  S SKBJCrCJDrDJErEJFrFJGrGJrJHrHJIrIJJrJJKrKJLrLJMrMJNrNJOrOJPrPJQrQJRrRJSrSJTrTJUrUJVrVJWrWJXrXJYrYJZrZJ[r[  S SK\J]r]  S SK^J_r_J`r`JaraJbrbJcrcJdrdJereJfrfJgrg  S SK^Jhri  S SK^Jjrk  S SK^Jlrm  S SKnJoroJprpJqrq  S SKrJsrs  S SKtJuru  S SKvJwrw  S SKxJyry  S SKzJ{r{  S SK|J}r}  S SK~Jr  S SKJr  S SKJr  S S KJrJr  \GR                  " \5         S S!KJrJr  SSS5        \(       a  \GR                  " \5         S SKJr  SSS5        S S"KJrJrJr  S SKrS SKJr  S S#KJrJrJr  S S$KJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJr  S S%K5Jr  \GR`                  S&:  a  S S'KJr  OS S'KJr  \GR`                  S(:  a  S S)KJ/r/  O%S S)KJ/r/  O\6(       a  \GRh                  \   r\=\l        \\\   S*S+S,S-S.S/S0S14	   r\ " S2 S*5      5       r      S4S3 jrg! , (       d  f       GN= f! , (       d  f       N= f)5    )annotationsN)IterableSequence)nullcontext)datedatetimetime	timedelta)Decimal)TYPE_CHECKINGAnyCallableClassVarLiteralNoReturnUnionoverload)	functions)arrow_to_pyseriesdataframe_to_pyseriesiterable_to_pyseriesnumpy_to_pyseriespandas_to_pyseriessequence_to_pyseriesseries_to_pyseries)date_to_intdatetime_to_inttime_to_inttimedelta_to_int)deprecate_renamed_parameter
deprecatedissue_deprecation_warningget_series_item_by_key)unstable)	BUILDING_SPHINX_DOCS_is_generator
no_defaultparse_versionqualified_type_namerequire_same_typescale_bytessphinx_accessorwarn_null_comparison)wrap_dfwrap_s)ArrayBooleanCategoricalDateDatetimer   DurationEnumFloat32Float64Int32Int64ListNullObjectStringTimeUInt16UInt32UInt64Unknownis_polars_dtype
maybe_castnumpy_char_code_to_dtypeparse_into_dtypesupported_numpy_char_code)dtype_to_init_repr)	_ALTAIR_AVAILABLE_PYARROW_AVAILABLE_check_for_numpy_check_for_pandas_check_for_pyarrow_check_for_torchaltairimport_optionaltorch)numpy)pandas)pyarrow)ComputeErrorModuleUpgradeRequiredError
ShapeError)CompatLevelArrayNameSpaceBinaryNameSpaceCatNameSpaceDateTimeNameSpaceListNameSpace)
SeriesPlotStringNameSpaceStructNameSpace)expr_dispatchget_ffi_func)PyDataFramePySeries)
Collection	GeneratorMapping)	DataFrameDataTypeExpr)ArrowArrayExportableArrowStreamExportable
BufferInfoClosedIntervalComparisonOperatorFillNullStrategyInterpolationMethodIntoExprIntoExprColumnMultiIndexSelectorNonNestedLiteralNullBehaviorNumericLiteralPolarsDataTypePythonLiteralQuantileMethod
RankMethod	RoundModeSearchSortedSideSeriesBuffersSingleIndexSelectorSizeUnitTemporalLiteral)	NoDefault)      )Self)r      )r!   Seriespa.Arrayzpa.ChunkedArraynp.ndarray[Any, Any]pd.Series[Any]zpd.DatetimeIndexrt   ru   c            
      !   \ rS rSr% SrSrS\S'   1 SkrS\S'      GSS	S
S.           GSS jjjr\	GSS j5       r
\	\" S5      GSS j5       5       r\	GSS j5       r\	GSS j5       rGSS jrGSS jrGSS jr\	        GSS j5       r\	 GS       GSS jj5       r\GSS j5       r\GSS j5       r\GSS j5       r\GSS j5       r\GSS j5       rGSS jrGSS jrGSS jrGSS  jrGSS! jrGSS" jr \!GSS# j5       r"\!GSS$ j5       r"GSS% jr"\!GSS& j5       r#\!GSS' j5       r#GSS( jr#\!GSS) j5       r$\!GSS* j5       r$GSS+ jr$\!GSS, j5       r%\!GSS- j5       r%GSS. jr%\!GSS/ j5       r&\!GSS0 j5       r&GSS1 jr&\!GSS2 j5       r'\!GSS3 j5       r'GSS4 jr'GSS5 jr(\!GSS6 j5       r)\!GSS7 j5       r)GSS8 jr)\!GSS9 j5       r*\!GSS: j5       r*GSS; jr*\!GSS< j5       r+\!GSS= j5       r+GSS> jr+\!GSS? j5       r,\!GSS@ j5       r,GSSA jr,\!GSSB j5       r-\!GSSC j5       r-GSSD jr-\!GSSE j5       r.\!GSSF j5       r.GSSG jr.\!GSSH j5       r/\!GSSI j5       r/GSSJ jr/\!GSSK j5       r0\!GSSL j5       r0GSSM jr0\!GSSN j5       r1\!GSSO j5       r1GSSP jr1\!GSSQ j5       r2\!GSSR j5       r2GSSS jr2\!GSST j5       r3\!GSSU j5       r3GSSV jr3\!GSSW j5       r4\!GSSX j5       r4GSSY jr4\!GSSZ j5       r5\!GSS[ j5       r5GSS\ jr5\!GSS] j5       r6\!GSS^ j5       r6GSS_ jr6GSS` jr7\!GSSa j5       r8\!GSSb j5       r8\!GSSc j5       r8GSSd jr8\!GSSe j5       r9\!GSSf j5       r9GSSg jr9GSSh jr:\!GSSi j5       r;\!GSSj j5       r;GSSk jr;\!GSSl j5       r<\!GSSm j5       r<GSSn jr<GSSo jr=\!GSSp j5       r>\!GSSq j5       r>\!GSSr j5       r>GSSs jr>\!GSSt j5       r?\!GSSu j5       r?GSSv jr?GSSw jr@GSSx jrAGSSy jrBGSSz jrCGSS{ jrDGSS| jrEGSS} jrFGSS~ jrGGSS jrHGSS jrIGSS jrJGSS jrKGSS jrLGSS jrMGSGSS jjrNGSS jrOGSS jrP\!GSS j5       rQ\!GSS j5       rQ    GSS jrQ      GSS jrR GS     GSS jjrS          GSS jrTGSGSS jjrUGSS jrVGSGSS jjrWGSGSS jjrXGSS jrYGSS jrZ\!SS.GSS jj5       r[\!GSS j5       r[S	S.GSS jjr[\!SS.GSS jj5       r\\!GSS j5       r\S	S.GSS jjr\\]R                  4GSS jjr_GSS jr`GSS jraGSS jrbGSS jrcGSS jrdGSGSS jjre  GS     GSS jjrfGSS jrgGSS jrhGSS jriGSS jrjGSS jrkGSS jrlGSS jrmGSS jrnGSGSS jjroGSGSS jjrpGSS jrq GS     GSS jjrrSS
S
S.       GSS jjrs\t" 5       SS
S
S.         GSS jj5       ru\t" 5       SS
S
S
S.           GSS jj5       rvGSS jrwGSS jrx\t" 5        GSSS	S	S.         GSS jjj5       ryS
S
SS
S.         GSS jjrzGSS jr{\]R                  4S	S.GSS jjjr|\t" 5       \}" SSSS9SS
S.       GSS jj5       5       r~GSS jrGSS jrGSS jrGSS jrS
S.GSS jjrS
S.GSS jjrS
S.GSS jjrS
S.GSS jjrS
S.GSS jjrGSGSS jjrGSS jrGSS jrGSS jrGSGSS jjrGSGSS jjrGSGSS jjrGSGSS jjrS
S
S	S
S.         GSS jjrGSGSS jjr GSS
S.       GSS jjjrGSGSS jjr GSS
S.       GSS jjjrS
S
S.GSS jjrGSS jrGSS jrGSS jr\! GSSS.       GSS jjj5       r\! GSSS.       GSS jjj5       r GSS
S.       GSS jjjrS
S.GSS jjr    GSS jrGSS jrGSS jr\" S5      GSS j5       rGSS jrS
S
S.GSS jjrGSS jrGSS jrGSS jrGSS jrGSS jrGSS jrGSS jrS
S.     GSS jjrGSS jrGSS jrGSS jrGSS jrGSS jrGSGS  jr\}" SGSGSS9S
S
S	GS.         GSGS jj5       rS	S
GS.       GSGS jjrGSGS jrGSGS jrS
GS	.GS GS
 jjrGSGS jr GS       GSGS jjrGSGSS
GS.         GSGS jjrS
S	SSGS.         GSGS jjr\t" 5       GSGSGS jj5       r\t" 5       GSGS j5       r\}" GSGSGSS9SGS.GSGS jj5       rS
GS.     GSGS jjrGS	GS
GS jjrGSGS jrGSGS jrGSGS jr      GSGS  jrGSGS! jrGSGSGS" jjrGSGS# jrGSGS$ jr   GS       GSGS% jjrGSGSGS& jjrGSGSGS' jjrGSGS( jrGSGS) jrGSGSGS* jjrGSGS+ jrGSGS, jrGSGS- jrGSGS. jrGSGS/ jrGSGS0 jrGSGS1 jrGSGS2 jrGSGS3 jrGSGS4 jrGSGS5 jrGSGS6 jrGSGS7 jrGSGS8 jrGSGS9 jrGSGS: jrGSGS; jr GSS	GS<.       GSGS= jjjrGSSGS>.GSGS? jjjrGSGS@ jr\t" 5       SGSAGSB.         GSGSC jj5       r\}" SSSS9 GSSS
GSD.         GSGSE jjj5       r\t" 5       SGSAGSB.         GSGSF jj5       r\}" SSSS9 GSSS
GSD.         GSGSG jjj5       r\t" 5       SGSAGSB.         GSGSH jj5       r\}" SSSS9 GSSS
GSD.         GSGSI jjj5       r\t" 5       SGSAGSB.         GSGSJ jj5       r\}" SSSS9 GSSS
GSD.         GSGSK jjj5       r\t" 5       SGSASGSL.           GSGSM jj5       r\}" SSSS9 GSSS
SGSN.           GSGSO jjj5       r\t" 5       SGSASGSL.           GSGSP jj5       r\}" SSSS9 GSSS
SGSN.           GSGSQ jjj5       r\t" 5       \}" SSSS9 GSSS
GSD.           GSGSR jjj5       5       r\t" 5       SGSAGSB.         GSGSS jj5       r\t" 5       \}" SSSS9 GSSS
GSD.         GSGST jjj5       5       r\t" 5       SSGSAGSU.             GSGSV jj5       r\t" 5       \}" SSSS9   GSSS
GSD.             GSGSW jjj5       5       r\t" 5       S	SS
GSX.         GS GSY jj5       r\t" 5       S	S	SS
GSZ.           GS!GS[ jj5       r GSSS
S
SGS\.           GS"GS] jjjrGSGS^ jrGSGS_ jrGSGS` jrS
GS	.GS#GSa jjr    GS$         GS%GSb jjrS	GSc.GS&GSd jjrGS'GS(GSe jjrGS)GSf jrGSGSg jr GS*S
SGSh.       GS+GSi jjjrGS,GS-GSj jjrGSGS.GSk jjrS	GSl.GS/GSm jjrS	S	GSn.GS0GSo jjGr   GS     GS1GSp jjGrGSGSq jGrGSGSr jGrG\4G\SGSs.         GS2GSt jjjGrG\4G\SGSs.         GS2GSu jjjGrGS3GSv jGrGSGS4GSw jjGr\}" SSSS9SSSSS	SS
GSx.               GS5GSy jj5       Gr	      GS6GSz jGr
\}" SSSS9SSSSS	S
SS
GS{.                 GS7GS| jj5       Gr\}" SSSS9SSSSS	S
SS
GS{.                 GS7GS} jj5       GrGS8GS~ jGrS
S.GS9GS jjGrGS:GS jGrGSGS jGrGS;GS jGrGSGS jGrGSGS jGrGSGS jGrGSGS jGrGSGS jGrGSGS jGrGSGS jGrGSGS jGrGSGS jGrGSGS jGrGSGS jGrGSGS jGrGSGS jGrS
SSGS.       GS<GS jjGrS
SSGS.           GS=GS jjGr GS>GS jGr!\GS?GS j5       Gr"\GS@GS j5       Gr#\GSAGS j5       Gr$\GSBGS j5       Gr%\GSCGS j5       Gr&\GSDGS j5       Gr'\GSEGS j5       Gr(\\t" 5       GSFGS j5       5       Gr)GSGr*g(G  r      a  
A Series represents a single column in a Polars DataFrame.

Parameters
----------
name : str, default None
    Name of the Series. Will be used as a column name when used in a DataFrame.
    When not specified, name is set to an empty string.
values : ArrayLike, default None
    One-dimensional data in various forms. Supported are: Sequence, Series,
    pyarrow Array, and numpy ndarray.
dtype : DataType, default None
    Data type of the resulting Series. If set to `None` (default), the data type is
    inferred from the `values` input. The strategy for data type inference depends
    on the `strict` parameter:

    - If `strict` is set to True (default), the inferred data type is equal to the
      first non-null value, or `Null` if all values are null.
    - If `strict` is set to False, the inferred data type is the supertype of the
      values, or :class:`Object` if no supertype can be found. **WARNING**: A full
      pass over the values is required to determine the supertype.
    - If no values were passed, the resulting data type is :class:`Null`.

strict : bool, default True
    Throw an error if any value does not exactly match the given or inferred data
    type. If set to `False`, values that do not match the data type are cast to
    that data type or, if casting is not possible, set to null instead.
nan_to_null : bool, default False
    In case a numpy array is used to create this Series, indicate how to deal
    with np.nan values. (This parameter is a no-op on non-numpy data).

Examples
--------
Constructing a Series by specifying name and values positionally:

>>> s = pl.Series("a", [1, 2, 3])
>>> s
shape: (3,)
Series: 'a' [i64]
[
        1
        2
        3
]

Notice that the dtype is automatically inferred as a polars Int64:

>>> s.dtype
Int64

Constructing a Series with a specific dtype:

>>> s2 = pl.Series("a", [1, 2, 3], dtype=pl.Float32)
>>> s2
shape: (3,)
Series: 'a' [f32]
[
    1.0
    2.0
    3.0
]

It is possible to construct a Series with values as the first positional argument.
This syntax considered an anti-pattern, but it can be useful in certain
scenarios. You must specify any other arguments through keywords.

>>> s3 = pl.Series([1, 2, 3])
>>> s3
shape: (3,)
Series: '' [i64]
[
        1
        2
        3
]
Nrm   _s>   dtarrbincatstrlistplotstructzClassVar[set[str]]
_accessorsTFstrictnan_to_nullr   c                  U[         :X  a  S nOUb  [        U5      (       d  [        U5      nS nUc  SnO-[        U[        5      (       a  UnOUc  UnSnOSn[        U5      e[        U[        5      (       a  [        UUUUUS9U l        g Uc  [        U/ US9U l        g [        U5      (       Ga-  [        U[        R                  5      (       Ga  [        XXES9U l        UR                  R                  [        R                  [        R                   4;   a  [#        S UR                  5      n[#        X2R                  5      nUbu  U R%                  USS9R%                  U5      R'                  [        R(                  " [        R*                  " U5      5      R-                  5       S 5      R                  U l        g Ub  U R%                  X4S9R                  U l        g g [/        U5      (       a^  [        U[0        R2                  5      (       a?  [        XR5                  SS9XES9U l        Ub  U R%                  X4S9R                  U l        g g [7        U5      (       a?  [        U[8        R:                  [8        R<                  45      (       a  [?        XX4S	9U l        g [A        U5      (       aN  [        U[B        RD                  [B        RF                  [B        RH                  45      (       a  [K        XX4S	9U l        g [M        US
5      (       d   [O        U5      (       a  [Q        XX4S	9U l        g [        U[D        5      (       a  [S        XbX4S	9U l        g [        U[T        RV                  5      (       a  [Y        XbX4S	9U l        g [M        US5      (       a  [Z        R\                  " U5      U l        g [M        US
5      (       a  [Z        R^                  " U5      U l        g S[        U5      R`                  < S3n[        U5      e)N zSeries name must be a string)dtyper   r   r   r   F)r   )force)r   r   __arrow_c_stream____arrow_c_array__z0Series constructor called with unsupported type z for the `values` parameter)1rD   rE   rH   
isinstancer   	TypeErrorr   r   r   rM   npndarrayr   r   type
datetime64timedelta64_resolve_temporal_dtypecastscatterargwhereisnatflattenrP   rS   TensorrT   rO   par1   ChunkedArrayr   rN   pdr   IndexDatetimeIndexr   hasattrr'   r   r   plrq   r   rm   from_arrow_c_arrayfrom_arrow_c_stream__name__)	selfnamevaluesr   r   r   original_namemsginput_dtypes	            gC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\polars/series/series.py__init__Series.__init__  sD    GEu'='=$U+E %)<Dc"" M~4n$fh''*'DG ^*45ADGf%%*VRZZ*H*H'VDG ||  R]]BNN$CC5dFLLI/||D$ 		+e	<e RXXf-=!>!F!F!H$O G  ))E)9<< ! f%%*VU\\*J*J'lll/DG  ))E)9<< !  ''JRXXr/-
 -
 (EQDGv&&:RYY"*:*:;,
 ,
 )URDG!566=;P;P*4uTDG''(UDG --+UDG V01111&9DGV122226:DG C4<CXCXB[-.  C.     c                4    U R                  U 5      nXl        U$ N)__new__r   )clspyseriesseriess      r   _from_pyseriesSeries._from_pyseries|  s    S!	r   z`_import_from_c` is deprecated; use `_import_arrow_from_c` instead. If you are using an extension, please compile it with the latest 'pyo3-polars'c                L    U R                  [        R                  " X5      5      $ r   r   rm   _import_arrow_from_cr   r   pointerss      r   _import_from_cSeries._import_from_c  s      !!("?"?"OPPr   c                L    U R                  [        R                  " X5      5      $ )a  
Construct a Series from Arrows C interface.

Parameters
----------
name
    The name that should be given to the `Series`.
pointers
    A list with tuples containing two entries:
     - The raw pointer to a C ArrowArray struct
     - The raw pointer to a C ArrowSchema struct

Warning
-------
This will read the `array` pointer without moving it. The host process should
garbage collect the heap pointer, but not its contents.
r   r   s      r   r   Series._import_arrow_from_c  s     & !!("?"?"OPPr   c                L    U R                  [        R                  " U5      5      $ r   )r   rm   _import)r   pointers     r   r   Series._import  s    !!("2"27";<<r   c                :    U R                   R                  X5        g)a  
Export to a C ArrowArray and C ArrowSchema struct, given their pointers.

Parameters
----------
out_ptr: int
    The raw pointer to a C ArrowArray struct.
out_schema_ptr: int (optional)
    The raw pointer to a C ArrowSchema struct.

Notes
-----
The series should only contain a single chunk. If you want to export all chunks,
first call `Series.get_chunks` to give you a list of chunks.

Warning
-------
Safety
This function will write to the pointers given in `out_ptr` and `out_schema_ptr`
and thus is highly unsafe.

Leaking
If you don't pass the ArrowArray struct to a consumer,
array memory will leak. This is a low-level function intended for
expert users.
N)r   _export_arrow_to_c)r   out_ptrout_schema_ptrs      r   r   Series._export_arrow_to_c  s    6 	""7;r   c                6    U R                   R                  5       $ )a|  
Return pointer, offset, and length information about the underlying buffer.

Returns
-------
tuple of ints
    Tuple of the form (pointer, offset, length)

Raises
------
TypeError
    If the `Series` data type is not physical.
ComputeError
    If the `Series` contains multiple chunks.

Notes
-----
This method is mainly intended for use with the dataframe interchange protocol.
)r   _get_buffer_infor   s    r   r   Series._get_buffer_info  s    ( ww''))r   c                    U R                   R                  5       nSn[        X!5       VVs0 s H  u  p4X4b  U R                  U5      OU_M     snn$ s  snnf )a  
Return the underlying values, validity, and offsets buffers as Series.

The values buffer always exists.
The validity buffer may not exist if the column contains no null values.
The offsets buffer only exists for Series of data type `String` and `List`.

Returns
-------
dict
    Dictionary with `"values"`, `"validity"`, and `"offsets"` keys mapping
    to the corresponding buffer or `None` if the buffer doesn't exist.

Warnings
--------
The underlying buffers for `String` Series cannot be represented in this
format. Instead, the buffers are converted to a values and offsets buffer.

Notes
-----
This method is mainly intended for use with the dataframe interchange protocol.
)r   validityoffsets)r   _get_bufferszipr   )r   bufferskeyskbs        r   r   Series._get_buffers  s]    . ''&&(0 D*
* t""1%A=*
 	
 
s   "Ac                N    U R                  [        R                  " XU5      5      $ )a  
Construct a Series from information about its underlying buffer.

Parameters
----------
dtype
    The data type of the buffer.
    Must be a physical type (integer, float, or boolean).
buffer_info
    Tuple containing buffer information in the form `(pointer, offset, length)`.
owner
    The object owning the buffer.

Returns
-------
Series

Raises
------
TypeError
    When the given `dtype` is not supported.

Notes
-----
This method is mainly intended for use with the dataframe interchange protocol.
)r   rm   _from_buffer)r   r   buffer_infoowners       r   r   Series._from_buffer  s"    < !!("7"7E"RSSr   c                    [        U[        5      (       a  UR                  /nOU Vs/ s H  oUR                  PM     nnSnUb  UR                  nU R                  [        R
                  " XU5      5      $ s  snf )av  
Construct a Series from information about its underlying buffers.

Parameters
----------
dtype
    The data type of the resulting Series.
data
    Buffers describing the data. For most data types, this is a single Series of
    the physical data type of `dtype`. Some data types require multiple buffers:

    - `String`: A data buffer of type `UInt8` and an offsets buffer
      of type `Int64`. Note that this does not match how the data
      is represented internally and data copy is required to construct
      the Series.
validity
    Validity buffer. If specified, must be a Series of data type `Boolean`.

Returns
-------
Series

Raises
------
TypeError
    When the given `dtype` is not supported or the other inputs do not match
    the requirements for constructing a Series of the given `dtype`.

Warnings
--------
Constructing a `String` Series requires specifying a values and offsets buffer,
which does not match the actual underlying buffers. The values and offsets
buffer are converted into the actual buffers, which copies data.

Notes
-----
This method is mainly intended for use with the dataframe interchange protocol.
N)r   r   r   r   rm   _from_buffers)r   r   datar   data_lstsvalidity_seriess          r   r   Series._from_buffers  so    Z dF##yH&*+ddH+/3&kkO!!""5OD
 	
	 ,s   A6c                 @    [         R                  " 5       R                  $ )zB
Get the newest supported compat level.

This is for pyo3-polars.
)rZ   _newest_version r   r   _newest_compat_levelSeries._newest_compat_levelM  s     ""$---r   c                6    U R                   R                  5       $ )zj
Get the data type of this Series.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3])
>>> s.dtype
Int64
)r   r   r   s    r   r   Series.dtypeV  s     ww}}r   c                    U R                   R                  5       U R                   R                  5       S.nU R                  [        :X  a  U R                   R                  5       US'   U$ )z
Get flags that are set on the Series.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3])
>>> s.flags
{'SORTED_ASC': False, 'SORTED_DESC': False}
)
SORTED_ASCSORTED_DESCFAST_EXPLODE)r   is_sorted_ascending_flagis_sorted_descending_flagr   r<   can_fast_explode_flag)r   outs     r   flagsSeries.flagsc  sU     ''::<77<<>
 ::"&''"?"?"AC
r   c                6    U R                   R                  5       $ )zb
Get the name of this Series.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3])
>>> s.name
'a'
)r   r   r   s    r   r   Series.namev  s     ww||~r   c                8    U R                   R                  5       4$ )z]
Shape of this Series.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3])
>>> s.shape
(3,)
r   lenr   s    r   shapeSeries.shape  s     r   c                    Sn[        U5      e)Na  the truth value of a Series is ambiguous

Here are some things you might want to try:
- instead of `if s`, use `if not s.is_empty()`
- instead of `s1 and s2`, use `s1 & s2`
- instead of `s1 or s2`, use `s1 | s2`
- instead of `s in [y, z]`, use `s.is_in([y, z])`
)r   r   r   s     r   __bool__Series.__bool__  s    B 	 nr   c                6    U R                   R                  5       $ r   )r   __getstate__r   s    r   r  Series.__getstate__  s    ww##%%r   c                l    [        5       R                  U l        U R                  R                  U5        g r   )r   r   __setstate__)r   states     r   r!  Series.__setstate__  s!    (++U#r   c                    U R                   R                  5       nUR                  SU R                  R                   S5      $ )Nr      )r   as_strreplace	__class__r   )r   s_reprs     r   __str__Series.__str__  s2    ggnn&~~h4>>+B+B*CaHHr   c                "    U R                  5       $ r   )r*  r   s    r   __repr__Series.__repr__  s    ||~r   c                "    U R                  5       $ r   r  r   s    r   __len__Series.__len__      xxzr   c                    g r   r  r   others     r   __and__Series.__and__      ,/r   c                    g r   r  r5  s     r   r7  r8        -0r   c                   [        U[        R                  5      (       a  [        R                  " U 5      U-  $ [        U[
        5      (       d  [        U/5      nU R                  U R                  R                  UR                  5      5      $ r   )	r   r   rs   Flitr   r   r   bitandr5  s     r   r7  r8    `    eRWW%%55;&&%((E7OE""477>>%((#;<<r   c                    g r   r  r5  s     r   __rand__Series.__rand__  r;  r   c                    g r   r  r5  s     r   rB  rC        .1r   c                    [        U[        R                  5      (       a  U[        R                  " U 5      -  $ [        U[
        5      (       d  [        U/5      nX-  $ r   r   r   rs   r=  r>  r   r5  s     r   rB  rC    F    eRWW%%155;&&%((E7OE|r   c                    g r   r  r5  s     r   __or__Series.__or__      +.r   c                    g r   r  r5  s     r   rJ  rK    r9  r   c                   [        U[        R                  5      (       a  [        R                  " U 5      U-  $ [        U[
        5      (       d  [        U/5      nU R                  U R                  R                  UR                  5      5      $ r   )	r   r   rs   r=  r>  r   r   r   bitorr5  s     r   rJ  rK    s`    eRWW%%55;&&%((E7OE""477==#:;;r   c                    g r   r  r5  s     r   __ror__Series.__ror__  r9  r   c                    g r   r  r5  s     r   rQ  rR    r;  r   c                    [        U[        R                  5      (       a  U[        R                  " U 5      -  $ [        U[
        5      (       d  [        U/5      nX-  $ r   rG  r5  s     r   rQ  rR    rH  r   c                    g r   r  r5  s     r   __xor__Series.__xor__  r9  r   c                    g r   r  r5  s     r   rV  rW    r;  r   c                   [        U[        R                  5      (       a  [        R                  " U 5      U-  $ [        U[
        5      (       d  [        U/5      nU R                  U R                  R                  UR                  5      5      $ r   )	r   r   rs   r=  r>  r   r   r   bitxorr5  s     r   rV  rW    r@  r   c                    g r   r  r5  s     r   __rxor__Series.__rxor__  r;  r   c                    g r   r  r5  s     r   r\  r]    rE  r   c                    [        U[        R                  5      (       a  U[        R                  " U 5      -  $ [        U[
        5      (       d  [        U/5      nX-  $ r   rG  r5  s     r   r\  r]    rH  r   c                
   U R                   [        :X  a\  [        U[        5      (       aG  US;   aA  USL a  US:X  d  USL a  US:X  a  U R	                  5       $ USL a  US:X  d  USL a	  US:X  a  U ) $ GOG[        U[
        5      (       an  U R                   R                  5       (       aO  U R                  [        5      n [        US-   [        U R                  5      nUc   eU R                  U" U5      5      $ [        U[        5      (       Ga  U R                   [        :X  a  U R                  [        S5      5      n SnOU R                   [        :X  an  U R                   R                  n[!        UR"                  5      [!        U5      :w  a  SUR"                  < S	U< 3n[%        U5      eU R                   R&                  nOS
U R                    3n[)        U5      e[+        X5      n[        US-   [,        U R                  5      nUc   eU R                  U" U5      5      $ [        U[.        5      (       aY  U R                   [0        :X  aE  [3        U5      n[        US-   [,        U R                  5      nUc   eU R                  U" U5      5      $ [        U[4        5      (       ao  U R                   [6        :X  a[  U R                   R&                  n[9        X5      n	[        US-   [,        U R                  5      nUc   eU R                  U" U	5      5      $ U R                   [:        [<        4;   a"  [        U[>        5      (       d  [?        U/5      nOn[        U[@        5      (       aY  U R                   [        :X  aE  [C        U5      n[        US-   [D        U R                  5      nUc   eU R                  U" U5      5      $ [        U[F        5      (       am  [        U[         5      (       dX  U R                   [H        [J        4;   a  U/n[?        SU5      nUR                   [L        :X  a  UR                  U R                   5        [        U[>        5      (       a5  U R                  [O        U R                  U5      " UR                  5      5      $  [        US-   U R                   U R                  5      nUc  SU R                    SU S3n[Q        U5      eUb  [S        XR                   5      nU R                  U" U5      5      $ ! [P         a    S n N^f = f)N)eqneqTra  Frb  z_<>uszdatetime time zone z  does not match Series timezone z3cannot compare datetime.datetime to Series of type r   Series of type z does not have z	 operator)*r   r2   r   boolclonefloat
is_integerr   r9   rk   r   r   r   r4   r5   	time_zoner   tzinfor   	time_unit
ValueErrorr   r;   r	   r@   r   r
   r6   r   r3   r7   r   r   r   r:   r   r<   r1   r=   getattrNotImplementedErrorrF   )
r   r6  opfrk  ri  r   tsdtds
             r   _compSeries._comp  s   :: Zt%<%<}AT"*%5.R5[zz|#5.R4ZUd]rU{uu%%$***?*?*A*A99W%DR%Z$'':A= =&&qx00x((zzT!yy$0 	x' JJ00	u||$I6//??_`i_lmC#C.( JJ00	KDJJ<X o% 2BR%Z8A= =&&qu--t$$t);E"AR%Z8A= =&&qt,,y))djjH.D

,,I!%3BR%Z8A= =&&qu--ZZK..z%7P7PE7OEt$$t);E"AR%Z8A= =&&qt,,eX&&z%/E/EzzdE]*2u%E{{d"

4::&eV$$&&wtww';EHH'EFF	R%ZTWW=A 9#DJJ<rd)LC%c**ujj1E""1U8,, # 	A	s   $S9 9TTc                    g r   r  r5  s     r   __eq__Series.__eq__I  rL  r   c                    g r   r  r5  s     r   rw  rx  L      /2r   c                    [        U5        [        U[        R                  5      (       a%  [        R
                  " U 5      R                  U5      $ U R                  US5      $ )Nra  )r.   r   r   rs   r=  r>  rw  rt  r5  s     r   rw  rx  O  E    U#eRWW%%55;%%e,,zz%&&r   c                    g r   r  r5  s     r   __ne__Series.__ne__U  rL  r   c                    g r   r  r5  s     r   r~  r  X  rz  r   c                    [        U5        [        U[        R                  5      (       a%  [        R
                  " U 5      R                  U5      $ U R                  US5      $ )Nrb  )r.   r   r   rs   r=  r>  r~  rt  r5  s     r   r~  r  [  sE    U#eRWW%%55;%%e,,zz%''r   c                    g r   r  r5  s     r   __gt__Series.__gt__a  rL  r   c                    g r   r  r5  s     r   r  r  d  r9  r   c                    [        U5        [        U[        R                  5      (       a%  [        R
                  " U 5      R                  U5      $ U R                  US5      $ )Ngt)r.   r   r   rs   r=  r>  r  rt  r5  s     r   r  r  g  r|  r   c                    g r   r  r5  s     r   __lt__Series.__lt__m  rL  r   c                    g r   r  r5  s     r   r  r  p  r9  r   c                    [        U5        [        U[        R                  5      (       a%  [        R
                  " U 5      R                  U5      $ U R                  US5      $ )Nlt)r.   r   r   rs   r=  r>  r  rt  r5  s     r   r  r  s  r|  r   c                    g r   r  r5  s     r   __ge__Series.__ge__y  rL  r   c                    g r   r  r5  s     r   r  r  |  r9  r   c                    [        U5        [        U[        R                  5      (       a%  [        R
                  " U 5      R                  U5      $ U R                  US5      $ )Ngt_eq)r.   r   r   rs   r=  r>  r  rt  r5  s     r   r  r    E    U#eRWW%%55;%%e,,zz%))r   c                    g r   r  r5  s     r   __le__Series.__le__  rL  r   c                    g r   r  r5  s     r   r  r    r9  r   c                    [        U5        [        U[        R                  5      (       a%  [        R
                  " U 5      R                  U5      $ U R                  US5      $ )Nlt_eq)r.   r   r   rs   r=  r>  r  rt  r5  s     r   r  r    r  r   c                    g r   r  r5  s     r   le	Series.le      '*r   c                    g r   r  r5  s     r   r  r        (+r   c                $    U R                  U5      $ )z;Method equivalent of operator expression `series <= other`.)r  r5  s     r   r  r        {{5!!r   c                    g r   r  r5  s     r   r  	Series.lt  r  r   c                    g r   r  r5  s     r   r  r    r  r   c                $    U R                  U5      $ )z:Method equivalent of operator expression `series < other`.)r  r5  s     r   r  r    r  r   c                    g r   r  r5  s     r   ra  	Series.eq  r  r   c                    g r   r  r5  s     r   ra  r    r  r   c                $    U R                  U5      $ )z;Method equivalent of operator expression `series == other`.)rw  r5  s     r   ra  r    r  r   c                    g r   r  r5  s     r   
eq_missingSeries.eq_missing  rz  r   c                    g r   r  r5  s     r   r  r        03r   c                >   [        U[        R                  5      (       a%  [        R                  " U 5      R                  U5      $ U R                  5       R                  [        R                  " U R                  5      R                  U5      5      R                  5       $ )a  
Method equivalent of equality operator `series == other` where `None == None`.

This differs from the standard `eq` where null values are propagated.

Parameters
----------
other
    A literal or expression value to compare with.

See Also
--------
ne_missing
eq

Examples
--------
>>> s1 = pl.Series("a", [333, 200, None])
>>> s2 = pl.Series("a", [100, 200, None])
>>> s1.eq(s2)
shape: (3,)
Series: 'a' [bool]
[
    false
    true
    null
]
>>> s1.eq_missing(s2)
shape: (3,)
Series: 'a' [bool]
[
    false
    true
    true
]
)r   r   rs   r=  r>  r  to_frameselectcolr   	to_seriesr5  s     r   r  r    g    J eRWW%%55;))%00}}%%aeeDII&6&A&A%&HISSUUr   c                    g r   r  r5  s     r   ne	Series.ne  r  r   c                    g r   r  r5  s     r   r  r    r  r   c                $    U R                  U5      $ )z;Method equivalent of operator expression `series != other`.)r~  r5  s     r   r  r    r  r   c                    g r   r  r5  s     r   
ne_missingSeries.ne_missing  rz  r   c                    g r   r  r5  s     r   r  r    r  r   c                >   [        U[        R                  5      (       a%  [        R                  " U 5      R                  U5      $ U R                  5       R                  [        R                  " U R                  5      R                  U5      5      R                  5       $ )a  
Method equivalent of equality operator `series != other` where `None == None`.

This differs from the standard `ne` where null values are propagated.

Parameters
----------
other
    A literal or expression value to compare with.

See Also
--------
eq_missing
ne

Examples
--------
>>> s1 = pl.Series("a", [333, 200, None])
>>> s2 = pl.Series("a", [100, 200, None])
>>> s1.ne(s2)
shape: (3,)
Series: 'a' [bool]
[
    true
    false
    null
]
>>> s1.ne_missing(s2)
shape: (3,)
Series: 'a' [bool]
[
    true
    false
    false
]
)r   r   rs   r=  r>  r  r  r  r  r   r  r5  s     r   r  r    r  r   c                    g r   r  r5  s     r   ge	Series.ge  r  r   c                    g r   r  r5  s     r   r  r    r  r   c                $    U R                  U5      $ )z;Method equivalent of operator expression `series >= other`.)r  r5  s     r   r  r    r  r   c                    g r   r  r5  s     r   r  	Series.gt!  r  r   c                    g r   r  r5  s     r   r  r  $  r  r   c                $    U R                  U5      $ )z:Method equivalent of operator expression `series > other`.)r  r5  s     r   r  r  '  r  r   c                   [        U[        R                  5      (       a.  U R                  5       R	                  U5      R                  5       nOUc  [        R                  " SS /5      n[        U[        5      (       a5  U R                  [        U R                  U5      " UR                  5      5      $ [        U5      (       a]  [        U[        R                  5      (       a>  U R                  [        U R                  U5      " [        U5      R                  5      5      $ [        U[        [        [        [         ["        45      (       a  U R$                  R'                  5       (       dr  [)        U R*                  U/5      nSU;   a*  U R                  [        XB5      " U R                  5      5      $ U R                  [        U R                  U5      " U5      5      $ U R$                  R-                  5       (       a  [        U[.        [0        45      (       a  [        U[0        5      (       aI  [)        U R*                  U/5      nU R                  U5      R3                  [5        SS95      R                  nO[)        U R*                  U/[4        S9nSU;   a*  U R                  [        XB5      " U R                  5      5      $ U R                  [        U R                  U5      " U5      5      $ [7        XR$                  5      n[9        X0R$                  U R                  5      nUc2  SU R$                  < S[;        U5      R<                  < 3n[?        U5      eU R                  U" U5      5      $ )Nr   rhsr   )scaler   z+cannot do arithmetic with Series of dtype: z and argument of type: ) r   r   rs   r  
select_seqr  r   r   rm  r   rM   r   r   rg  r   r   r
   r   r   is_floatr   r   
is_decimal	PyDecimalintr   r   rF   rk   r   r   r   )r   r6  op_sop_ffir   r   rp  r   s           r   _arithmeticSeries._arithmetic+  s|   eRWW%%MMO..u5??AE]IIb4&)EeV$$&&wtww'=ehh'GHHe$$E2::)F)F&&wtww'=fUm>N>N'OPPuudHiEFFJJ''))%dii%9B**72+<TWW+EFF**7477D+A"+EFF::  ""z%)S9I'J'J%%%/		E7C((277a8HILL)$))eWGL**72+<TWW+EFF**7477D+A"+EFFujj1EVZZ9A9=djj^ L!%[1146  C. ""1U8,,r   c                    g r   r  r5  s     r   __add__Series.__add__V      69r   c                    g r   r  r5  s     r   r  r  Y  r9  r   c                    g r   r  r5  s     r   r  r  \  rL  r   c                4   [        U[        5      (       a  [        SU/5      nO[[        U[        R                  5      (       a  X-   $ [        U[        R
                  5      (       a  [        R                  " U 5      U-   $ U R                  R                  5       (       ai  [        U[        [        45      (       aN  U R                  5       R                  [        R                  " U R                  5      U-   5      R!                  5       $ U R#                  USS5      $ )Nr   addzadd_<>)r   r   r   r   rq   rs   r=  r>  r   r  rg  r  r  r  r  r   r  r  r5  s     r   r  r  _  s    eS!!2w'Er||,,<rww''55;&&::  ""z%%'F'F==?))!%%		*:U*BCMMOOuh77r   c                    g r   r  r5  s     r   __sub__Series.__sub__j  r9  r   c                    g r   r  r5  s     r   r  r  m  rL  r   c                   [        U[        R                  5      (       a  [        R                  " U 5      U-
  $ U R
                  R                  5       (       ai  [        U[        [        45      (       aN  U R                  5       R                  [        R                  " U R                  5      U-
  5      R                  5       $ U R                  USS5      $ )Nsubzsub_<>)r   r   rs   r=  r>  r   r  rg  r  r  r  r  r   r  r  r5  s     r   r  r  p  s    eRWW%%55;&&::  ""z%%'F'F==?))!%%		*:U*BCMMOOuh77r   c                Z   ^^ SUU4S jjmU R                  T" U R                  5      5      $ )zt
Convert leaf dtype the to given primitive datatype.

This is equivalent to logic in DataType::cast_leaf() in Rust.
c                   > [        U [        5      (       a$  [        T" U R                  5      U R                  S9$ [        U [        5      (       a  [	        T" U R                  5      5      $ T$ )N)r  )r   r1   innerr  r<   )r   convert_to_primitive
leaf_dtypes    r   r  =Series._recursive_cast_to_dtype.<locals>.convert_to_primitive~  sS    %''1%++>ekkRR%&&0=>>r   )r   r   returnr   )r   r   )r   r  r  s    `@r   _recursive_cast_to_dtypeSeries._recursive_cast_to_dtypew  s(    	 	 yy-djj9::r   c                    g r   r  r5  s     r   __truediv__Series.__truediv__  r  r   c                    g r   r  r5  s     r   r  r        14r   c                   [        U[        R                  5      (       a  [        R                  " U 5      U-  $ U R
                  R                  5       (       a,  [        U R
                  [        5      (       d  Sn[        U5      e[        U[        [        45      (       a  U R
                  R                  5       (       d  [        U R
                  [        5      (       aN  U R                  5       R                  [        R                  " U R                  5      U-  5      R!                  5       $ U R
                  R#                  5       (       d  U R
                  R                  5       (       dd  [        U R
                  [$        [&        [        45      (       d:  [        U[(        5      (       a'  [        UR
                  [$        [&        45      (       a  U OU R+                  [-        5       5      n U R/                  USS5      $ )N5first cast to integer before dividing datelike dtypesdivzdiv_<>)r   r   rs   r=  r>  r   is_temporalr6   r   r  rg  r  r  r  r  r   r  r  r<   r1   r   r  r9   r  r   r6  r   s      r   r  r    sS   eRWW%%55;&&::!!##Jtzz8,L,LICC. ec5\**JJ!!##z$**h'G'G==?))!%%		*:U*BCMMOO
 

##%%::((**djj4*ABBuf--*U[[4QV-2X2X  ..wy9 	 uh77r   c                    g r   r  r5  s     r   __floordiv__Series.__floordiv__  r  r   c                    g r   r  r5  s     r   r  r    s    25r   c                   [        U[        R                  5      (       a  [        R                  " U 5      U-  $ U R
                  R                  5       (       a  Sn[        U5      eU R
                  R                  5       (       ai  [        U[        [        45      (       aN  U R                  5       R                  [        R                  " U R                  5      U-  5      R                  5       $ [        U[        R                  5      (       d  [        R                  " U5      nU R                  5       R!                  [        R                  " U R                  5      U-  5      R                  5       $ Nr  )r   r   rs   r=  r>  r   r  r   r  rg  r  r  r  r  r   r  r  r  s      r   r  r    s    eRWW%%55;%''::!!##ICC. ::  ""z%%'F'F==?))!%%		*:e*CDNNPP%))EE%LE}}))!%%		*:e*CDNNPPr   c                "    U R                  5       $ r   )not_r   s    r   
__invert__Series.__invert__  s    yy{r   c                    g r   r  r5  s     r   __mul__Series.__mul__  r9  r   c                    g r   r  r5  s     r   r  r    r  r   c                    g r   r  r5  s     r   r  r    r;  r   c                   [        U[        R                  5      (       a  [        R                  " U 5      U-  $ U R
                  R                  5       (       a,  [        U R
                  [        5      (       d  Sn[        U5      e[        U[        [        45      (       a  U R
                  R                  5       (       d  [        U R
                  [        5      (       aN  U R                  5       R                  [        R                  " U R                  5      U-  5      R!                  5       $ [        U[        R"                  5      (       a  X-  $ U R%                  USS5      $ Nz8first cast to integer before multiplying datelike dtypesmulzmul_<>)r   r   rs   r=  r>  r   r  r6   r   r  rg  r  r  r  r  r   r  rq   r  r  s      r   r  r    s    eRWW%%55;&&::!!##Jtzz8,L,LLCC. ec5\**JJ!!##z$**h'G'G==?))!%%		*:U*BCMMOOr||,,<##E5(;;r   c                    g r   r  r5  s     r   __mod__Series.__mod__  r9  r   c                    g r   r  r5  s     r   r	  r
    r;  r   c                   [        U[        R                  5      (       a%  [        R                  " U 5      R                  U5      $ U R                  R                  5       (       a  Sn[        U5      eU R                  R                  5       (       ai  [        U[        [        45      (       aN  U R                  5       R                  [        R                  " U R                  5      U-  5      R!                  5       $ U R#                  USS5      $ )N?first cast to integer before applying modulo on datelike dtypesremzrem_<>)r   r   rs   r=  r>  r	  r   r  r   r  rg  r  r  r  r  r   r  r  r  s      r   r	  r
    s    eRWW%%55;&&u--::!!##SCC. ::  ""z%%'F'F==?))!%%		*:U*BCMMOOuh77r   c                    U R                   R                  5       (       a  Sn[        U5      eU R                  USS5      $ )Nr  r  z
rem_<>_rhsr   r  r   r  r  s      r   __rmod__Series.__rmod__  s9    ::!!##SCC. ul;;r   c                b   [        U[        5      (       d:  [        U[        [        45      (       am  U R                  R                  5       (       aN  U R                  5       R                  U[        R                  " U R                  5      -   5      R                  5       $ U R                  USS5      $ )Nr  z
add_<>_rhs)r   r   r  rg  r   r  r  r  r=  r  r   r  r  r5  s     r   __radd__Series.__radd__  sy    eS!!usEl++

0E0E0G0G==?))%!%%		2B*BCMMOOul;;r   c                8   [        U[        [        45      (       am  U R                  R	                  5       (       aN  U R                  5       R                  U[        R                  " U R                  5      -
  5      R                  5       $ U R                  USS5      $ )Nr  z
sub_<>_rhs)r   r  rg  r   r  r  r  r=  r  r   r  r  r5  s     r   __rsub__Series.__rsub__  sl    ec5\**tzz/D/D/F/F==?))%!%%		2B*BCMMOOul;;r   c                R   U R                   R                  5       (       a  Sn[        U5      eU R                   R                  5       (       a  U R	                  U5        [        U[        [        45      (       am  U R                   R                  5       (       aN  U R                  5       R                  U[        R                  " U R                  5      -  5      R                  5       $ [        U[        5      (       a  [        U5      nU R                  [         5      R	                  U5      $ r  )r   r  r   r  __rfloordiv__r   r  rg  r  r  r  r=  r  r   r  r   r9   r  s      r   __rtruediv__Series.__rtruediv__  s    ::!!##ICC. ::  u%ec5\**tzz/D/D/F/F==?))%!%%		2B*BCMMOOeS!!%LEyy!//66r   c                    U R                   R                  5       (       a  Sn[        U5      eU R                  USS5      $ )Nr  r  z
div_<>_rhsr  r  s      r   r  Series.__rfloordiv__  s9    ::!!##ICC. ul;;r   c                   U R                   R                  5       (       a,  [        U R                   [        5      (       d  Sn[	        U5      e[        U[
        [        45      (       a  U R                   R                  5       (       d  [        U R                   [        5      (       aN  U R                  5       R                  U[        R                  " U R                  5      -  5      R                  5       $ U R                  USS5      $ r  )r   r  r   r6   r   r  rg  r  r  r  r=  r  r   r  r  r  s      r   __rmul__Series.__rmul__
  s    ::!!##Jtzz8,L,LLCC. ec5\**JJ!!##z$**h'G'G==?))%!%%		2B*BCMMOOuh77r   c                $    U R                  U5      $ r   )powr   exponents     r   __pow__Series.__pow__  s    xx!!r   c                    U R                  5       R                  U[        R                  " U R                  5      -  R                  U R                  5      5      R                  5       $ r   )r  r  r=  r  r   aliasr  r5  s     r   __rpow__Series.__rpow__  sB    MMOZ!%%		"2299$))DEY[	
r   c                    [        U[        5      (       d/  [        U5      (       a*  [        U[        R                  5      (       a  [        U5      nU R                  U5      $ r   r   r   rM   r   r   r   dotr5  s     r   
__matmul__Series.__matmul__  sC    eX&&U##
5"**(E(E5ME xxr   c                    [        U[        5      (       d/  [        U5      (       a*  [        U[        R                  5      (       a  [        U5      nUR                  U 5      $ r   r-  r5  s     r   __rmatmul__Series.__rmatmul__'  sA    eX&&U##
5"**(E(E5MEyyr   c                    U R                  5       R                  [        R                  " U R                  5      * 5      R                  5       $ r   )r  r  r=  r  r   r  r   s    r   __neg__Series.__neg__.  s2    }}))155+;*;<FFHHr   c                    U $ r   r  r   s    r   __pos__Series.__pos__1  s    r   c                "    U R                  5       $ r   )absr   s    r   __abs__Series.__abs__4  r3  r   c                "    U R                  5       $ r   rf  r   s    r   __copy__Series.__copy__7      zz|r   c                "    U R                  5       $ r   r?  )r   memos     r   __deepcopy__Series.__deepcopy__:  rB  r   c                    Uc  U R                  5       $ U R                  5       R                  R                  U5      R	                  5       $ r   )	has_nullsimploder   containsitem)r   rK  s     r   __contains__Series.__contains__=  s:    <>>##||~""++D16688r   c              #  \  #    U R                   [        [        4;   aA  U R                  R                  n[        U R                  5       5       H  nU" U5      v   M     g Sn[        SU R                  5       U5       H*  nU R                  XC5      R                  5        S h  vN   M,     g  N	7f)Nia  r   )	r   r<   r1   r   	get_indexranger  sliceto_list)r   rO  idxbuffer_sizeoffsets        r   __iter__Series.__iter__B  s     ::$& ))ITXXZ(n$ ) !K488:{;::f:BBDDD <Ds   BB, B*!
B,c                    g r   r  r   keys     r   __getitem__Series.__getitem__O  s    <?r   c                    g r   r  rY  s     r   r[  r\  R  s    >Ar   c                    [        X5      $ )a  
Get part of the Series as a new Series or scalar.

Parameters
----------
key
    Row(s) to select.

Returns
-------
Series or scalar, depending on `key`.

Examples
--------
>>> s = pl.Series("a", [1, 4, 2])
>>> s[0]
1
>>> s[0:2]
shape: (2,)
Series: 'a' [i64]
[
    1
    4
]
r#   rY  s     r   r[  r\  U  s    8 &d00r   c           	        [        U[        5      (       a'  [        U[        5      (       d  U R                  X5        g [        U[        5      (       a  [        U[
        5      (       dl  U R                  R                  5       (       d  U R                  R                  5       (       a  U R                  X5        g SU R                  < S3n[        U5      e[        U[        5      (       a  UR                  [        :X  a!  U R                  X5      R                  U l        g UR                  [        :X  a5  U R                  UR                  [         5      U5      R                  U l        g UR                  [         :X  a!  U R                  X5      R                  U l        g g [#        U5      (       a  [        U[$        R&                  5      (       a  UR                  [$        R(                  :X  a=  U R                  [$        R*                  " U5      S S 2S4   U5      R                  U l        g U R-                  [.        R0                  " S[$        R2                  " U[$        R4                  5      SS95      nU R7                  XB5        g [        U[8        [:        45      (       a0  U R-                  [=        SU[         S95      nU R7                  XB5        g SU< S	3n[        U5      e)
Nzcannot set Series of dtype: z- with list/tuple as value; use a scalar valuer   r   T)_strictr   zcannot use "z" for indexing)r   r  re  r   r   r   r   
is_numericr  r   r   r2   setr   rC   r   rB   rM   r   r   bool_r   r   rm   new_u32arrayuint32__setitem__r   tupler   )r   rZ  valuer   r   s        r   rg  Series.__setitem__s  s    c3
3(=(=LL$x((E31G1Gzz$$&&$***@*@*B*BS(.tzzn =& &  C. c6""yyG#((3.11f$,,sxx'7?BBf$,,s255 % c""z#rzz'B'ByyBHH$,,r{{3'71'=uEHH''$$R#ryy)A4P   *dE]++##$8S$OPAQ& ~6CC. r   c                   Uc?  U R                  5       (       d*  U R                  [        :X  a  [        R                  " S5      nUc  Su  p4O%USL a  Su  p4OUSL a  Su  p4OSU< 3n[	        U5      eU R                  X4S9nUbC  XR                  :w  a4  USL a  S	UR                   S
U S3n[        U5      eUR                  U5      nU$ )aW  
Return a NumPy ndarray with the given data type.

This method ensures a Polars Series can be treated as a NumPy ndarray.
It enables `np.asarray` and NumPy universal functions.

See the NumPy documentation for more information:
https://numpy.org/doc/stable/user/basics.interoperability.html#the-array-method

See Also
--------
__array_ufunc__
U)FTT)TTF)FFzinvalid input for `copy`: writable
allow_copyzcopy not allowed: cast from z to z prohibited)rH  r   r?   r   r   to_numpyRuntimeError	__array__)r   r   copyrn  ro  r   r   s          r   rr  Series.__array__  s    & =!1!1djjF6JHHSME<#. HjT\#- HjU]#/ Hj.th7CC. mmXmE))!3u}4SYYKtE7+V"3''--&C
r   c                \  ^^^^ U R                   R                  5       S:  a  U R                   R                  SS9  U R                   nUS:X  GaH  TR                  S:w  a  Sn[	        U5      e/ mU H  n[        U[        [        [        R                  45      (       a  TR                  U5        M@  [        U[        5      (       ar  UR                  5       nUR                   R                  5       S:  a  UR                   R                  SS9  TR                  UR                   R                  5       5        M  S[        U5      < SU< 3n[        U5      e   [        R                   " T6 R"                  n	TR$                   V
s/ s H  n
['        U
S   5      (       d  M  U
S   PM     nn
U H"  n[        R(                  " X5      (       d  M   Un	  O   S	T;   a/  [        R*                  " TR-                  S	5      5      R"                  OU	m[/        TR0                  5      nU(       ac  U R3                  5       (       a  S
n[5        U5      eTR0                  c   eTR0                  R7                  S5      u  pUS:X  a
  T" TS	T0TD6$ X:H  nOSn[9        S[;        T5      U5      nUc  S[;        T5       S3n[	        U5      eU" UUUU4S jU5      nU R=                  U5      nU(       a  U$ U R?                  5       nU H-  n[        U[        5      (       d  M  UUR?                  5       -  nM/     URA                  5       RC                  [D        RF                  " U5      RI                  [D        RJ                  " U RL                  5      5      5      RO                  S5      $ SU< S3n[	        U5      es  sn
f )zNumpy universal functions.r%  Tin_place__call__z2only ufuncs that return one 1D array are supportedzunsupported type z for r   zcan't pass a Series with missing data to a generalized ufunc, as it might give unexpected results. See https://docs.pola.rs/user-guide/expressions/missing-data/ for suggestions on how to remove or fill in missing data.z->z()zapply_ufunc_<>zcould not find `apply_ufunc_`c                   > T" TU TS.TD6$ )N)r  r   r  )r  args
dtype_charkwargsufuncs    r   <lambda>(Series.__array_ufunc__.<locals>.<lambda>#  s    E4S
MfMr   r   zBonly `__call__` is implemented for numpy ufuncs on a Series, got `)(r   n_chunksrechunknoutrn  r   r  rg  r   r   appendr   to_physicalto_numpy_viewr*   r   result_typechartypesrI   can_castr   popre  	signaturerH  rW   splitrk   rG   r   is_not_nullr  r  r=  whenthenr  r   r  )r   r  methodinputsr~  r   r   argphys_argdtype_char_minimuminput_output_typedtypes_ufuncdtype_ufuncis_generalized_ufuncufunc_inputufunc_outputallocate_outputrp  r   resultvalidity_maskr|  r}  s    `  `                @@r   __array_ufunc__Series.__array_ufunc__  sT    77!GGOOTO*GGZzzQJ)#..=?DcC

#;<<KK$V,,"0H{{++-1 ++T+:KK 9 9 ;<-.A#.F-IsgVC#C.(  ')nnd&;&@&@ */)4%,->r-BC &!"%)4    ,;;1??)4&  , f$ G,-22'  $(#8 # >>## wC&s++
 222,1OO,A,A$,G)4' !$CjCFCC&1&AO"&-/G
/SUVWAy$$<Z$H#IL  *#..MF
 ((0F#  !,,.Mc6**!S__%66M  !}-221553CDE1:Q   &c**cs   N)	N)c                8    U R                   R                  U5      $ )z
Export a Series via the Arrow PyCapsule Interface.

https://arrow.apache.org/docs/dev/format/CDataInterface/PyCapsuleInterface.html
)r   r   )r   requested_schemas     r   r   Series.__arrow_c_stream__?  s     ww))*:;;r   c                <    U R                  5       R                  SS9$ )z<Format output data in HTML for display in Jupyter Notebooks.T)_from_series)r  _repr_html_r   s    r   r  Series._repr_html_G  s    }}***==r   c                    UcD  [        U 5      S:w  a  S[        U 5       S3n[        U5      eU R                  R                  S5      $ U R                  R	                  U5      $ )aX  
Return the Series as a scalar, or return the element at the given index.

If no index is provided, this is equivalent to `s[0]`, with a check
that the shape is (1,). With an index, this is equivalent to `s[index]`.

Examples
--------
>>> s1 = pl.Series("a", [1])
>>> s1.item()
1
>>> s2 = pl.Series("a", [9, 8, 7])
>>> s2.cum_sum().item(-1)
24
r%  zlcan only call '.item()' if the Series is of length 1, or an explicit index is provided (Series is of length )r   )r  rl  r   rO  get_index_signed)r   indexr   s      r   rK  Series.itemK  sh      =4yA~NNQRVi[XY[  !o%77$$Q''ww''..r   c                L    U R                   R                  5       n[        X!5      $ )aK  
Return an estimation of the total (heap) allocated size of the Series.

Estimated size is given in the specified unit (bytes by default).

This estimation is the sum of the size of its buffers, validity, including
nested arrays. Multiple arrays may share buffers and bitmaps. Therefore, the
size of 2 arrays is not the sum of the sizes computed from this function. In
particular, [`StructArray`]'s size is an upper bound.

When an array is sliced, its allocated size remains constant because the buffer
unchanged. However, this function will yield a smaller number. This is because
this function returns the visible size of the buffer, not its total capacity.

FFI buffers are included in this estimation.

Notes
-----
For data with Object dtype, the estimated size only reports the pointer
size, which is a huge underestimation.

Parameters
----------
unit : {'b', 'kb', 'mb', 'gb', 'tb'}
    Scale the returned size to the given unit.

Examples
--------
>>> s = pl.Series("values", list(range(1_000_000)), dtype=pl.UInt32)
>>> s.estimated_size()
4000000
>>> s.estimated_size("mb")
3.814697265625
)r   estimated_sizer,   )r   unitszs      r   r  Series.estimated_sizef  s"    F WW##%2$$r   c                    g)a  
Compute the square root of the elements.

Syntactic sugar for

>>> pl.Series([1, 2]) ** 0.5
shape: (2,)
Series: '' [f64]
[
    1.0
    1.414214
]

Examples
--------
>>> s = pl.Series([1, 2, 3])
>>> s.sqrt()
shape: (3,)
Series: '' [f64]
[
    1.0
    1.414214
    1.732051
]
Nr  r   s    r   sqrtSeries.sqrt      r   c                    g)a  
Compute the cube root of the elements.

Optimization for

>>> pl.Series([1, 2]) ** (1.0 / 3)
shape: (2,)
Series: '' [f64]
[
    1.0
    1.259921
]

Examples
--------
>>> s = pl.Series([1, 2, 3])
>>> s.cbrt()
shape: (3,)
Series: '' [f64]
[
    1.0
    1.259921
    1.44225
]
Nr  r   s    r   cbrtSeries.cbrt  r  r   .ignore_nullsc                   g r   r  r   r  s     r   any
Series.any      ADr   c                   g r   r  r  s     r   r  r        9<r   c               4    U R                   R                  US9$ )a$  
Return whether any of the values in the column are `True`.

Only works on columns of data type :class:`Boolean`.

Parameters
----------
ignore_nulls

    * If set to `True` (default), null values are ignored. If there
      are no non-null values, the output is `False`.
    * If set to `False`, `Kleene logic`_ is used to deal with nulls:
      if the column contains any null values and no `True` values,
      the output is `None`.

    .. _Kleene logic: https://en.wikipedia.org/wiki/Three-valued_logic

Returns
-------
bool or None

Examples
--------
>>> pl.Series([True, False]).any()
True
>>> pl.Series([False, False]).any()
False
>>> pl.Series([None, False]).any()
False

Enable Kleene logic by setting `ignore_nulls=False`.

>>> pl.Series([None, False]).any(ignore_nulls=False)  # Returns None
r  )r   r  r  s     r   r  r        F ww{{{55r   c                   g r   r  r  s     r   all
Series.all  r  r   c                   g r   r  r  s     r   r  r    r  r   c               4    U R                   R                  US9$ )a  
Return whether all values in the column are `True`.

Only works on columns of data type :class:`Boolean`.

Parameters
----------
ignore_nulls

    * If set to `True` (default), null values are ignored. If there
      are no non-null values, the output is `True`.
    * If set to `False`, `Kleene logic`_ is used to deal with nulls:
      if the column contains any null values and no `False` values,
      the output is `None`.

    .. _Kleene logic: https://en.wikipedia.org/wiki/Three-valued_logic

Returns
-------
bool or None

Examples
--------
>>> pl.Series([True, True]).all()
True
>>> pl.Series([False, True]).all()
False
>>> pl.Series([None, True]).all()
True

Enable Kleene logic by setting `ignore_nulls=False`.

>>> pl.Series([None, True]).all(ignore_nulls=False)  # Returns None
r  )r   r  r  s     r   r  r    r  r   c                    g)z
Compute the logarithm to a given base.

Examples
--------
>>> s = pl.Series([1, 2, 3])
>>> s.log()
shape: (3,)
Series: '' [f64]
[
    0.0
    0.693147
    1.098612
]
Nr  )r   bases     r   log
Series.log  r  r   c                    g)z
Compute the natural logarithm of the input array plus one, element-wise.

Examples
--------
>>> s = pl.Series([1, 2, 3])
>>> s.log1p()
shape: (3,)
Series: '' [f64]
[
    0.693147
    1.098612
    1.386294
]
Nr  r   s    r   log1pSeries.log1p)  r  r   c                    g)z
Compute the base 10 logarithm of the input array, element-wise.

Examples
--------
>>> s = pl.Series([10, 100, 1000])
>>> s.log10()
shape: (3,)
Series: '' [f64]
[
    1.0
    2.0
    3.0
]
Nr  r   s    r   log10Series.log10:  r  r   c                    g)z
Compute the exponential, element-wise.

Examples
--------
>>> s = pl.Series([1, 2, 3])
>>> s.exp()
shape: (3,)
Series: '' [f64]
[
    2.718282
    7.389056
    20.085537
]
Nr  r   s    r   exp
Series.expK  r  r   c                    g)ar  
Drop all null values.

The original order of the remaining elements is preserved.

See Also
--------
drop_nans

Notes
-----
A null value is not the same as a NaN value.
To drop NaN values, use :func:`drop_nans`.

Examples
--------
>>> s = pl.Series([1.0, None, 3.0, float("nan")])
>>> s.drop_nulls()
shape: (3,)
Series: '' [f64]
[
        1.0
        3.0
        NaN
]
Nr  r   s    r   
drop_nullsSeries.drop_nulls\  r  r   c                    g)a  
Drop all floating point NaN values.

The original order of the remaining elements is preserved.

See Also
--------
drop_nulls

Notes
-----
A NaN value is not the same as a null value.
To drop null values, use :func:`drop_nulls`.

Examples
--------
>>> s = pl.Series([1.0, None, 3.0, float("nan")])
>>> s.drop_nans()
shape: (3,)
Series: '' [f64]
[
        1.0
        null
        3.0
]
Nr  r   s    r   	drop_nansSeries.drop_nansx  r  r   c                    [        U[        5      (       a.  [        [        U R	                  U5      R
                  /5      5      $ [        [        U R
                  /5      5      $ )u  
Cast this Series to a DataFrame.

Parameters
----------
name
    optionally name/rename the Series column in the new DataFrame.

Examples
--------
>>> s = pl.Series("a", [123, 456])
>>> df = s.to_frame()
>>> df
shape: (2, 1)
┌─────┐
│ a   │
│ --- │
│ i64 │
╞═════╡
│ 123 │
│ 456 │
└─────┘

>>> df = s.to_frame("xyz")
>>> df
shape: (2, 1)
┌─────┐
│ xyz │
│ --- │
│ i64 │
╞═════╡
│ 123 │
│ 456 │
└─────┘
)r   r   r/   rl   renamer   r   r   s     r   r  Series.to_frame  sJ    H dC  ;D(9(<(<'=>??{DGG9-..r   nearestc                    U R                  5       R                  UUS9nSS/Ul        UR                  [        R
                  " S5      R                  5       5      $ )u@  
Quick summary statistics of a Series.

Series with mixed datatypes will return summary statistics for the datatype of
the first value.

Parameters
----------
percentiles
    One or more percentiles to include in the summary statistics (if the
    Series has a numeric dtype). All values must be in the range `[0, 1]`.
interpolation : {'nearest', 'higher', 'lower', 'midpoint', 'linear', 'equiprobable'}
    Interpolation method used when calculating percentiles.

Notes
-----
The median is included by default as the 50% percentile.

Returns
-------
DataFrame
    Mapping with summary statistics of a Series.

Examples
--------
>>> s = pl.Series([1, 2, 3, 4, 5])
>>> s.describe()
shape: (9, 2)
┌────────────┬──────────┐
│ statistic  ┆ value    │
│ ---        ┆ ---      │
│ str        ┆ f64      │
╞════════════╪══════════╡
│ count      ┆ 5.0      │
│ null_count ┆ 0.0      │
│ mean       ┆ 3.0      │
│ std        ┆ 1.581139 │
│ min        ┆ 1.0      │
│ 25%        ┆ 2.0      │
│ 50%        ┆ 3.0      │
│ 75%        ┆ 4.0      │
│ max        ┆ 5.0      │
└────────────┴──────────┘

Non-numeric data types may not have all statistics available.

>>> s = pl.Series(["aa", "aa", None, "bb", "cc"])
>>> s.describe()
shape: (4, 2)
┌────────────┬───────┐
│ statistic  ┆ value │
│ ---        ┆ ---   │
│ str        ┆ str   │
╞════════════╪═══════╡
│ count      ┆ 4     │
│ null_count ┆ 1     │
│ min        ┆ aa    │
│ max        ┆ cc    │
└────────────┴───────┘
)percentilesinterpolation	statisticri  )r  describecolumnsfilterr=  r  r  )r   r  r  statss       r   r  Series.describe  sT    B ((#' ) 
 %g.||AEE'N66899r   c                6    U R                   R                  5       $ )a  
Reduce this Series to the sum value.

Notes
-----
* Dtypes in {Int8, UInt8, Int16, UInt16} are cast to
  Int64 before summing to prevent overflow issues.
* If there are no non-null values, then the output is `0`.
  If you would prefer empty sums to return `None`, you can
  use `s.sum() if s.count() else None` instead
  of `s.sum()`.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3])
>>> s.sum()
6
)r   sumr   s    r   r  
Series.sum  s    & ww{{}r   c                6    U R                   R                  5       $ )zm
Reduce this Series to the mean value.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3])
>>> s.mean()
2.0
)r   meanr   s    r   r  Series.mean  s     ww||~r   c                6    U R                   R                  5       $ )a7  
Reduce this Series to the product value.

Notes
-----
If there are no non-null values, then the output is `1`.
If you would prefer empty products to return `None`, you can
use `s.product() if s.count() else None` instead
of `s.product()`.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3])
>>> s.product()
6
)r   productr   s    r   r  Series.product%  s    " ww  r   c                *   [        U5      (       a*  [        U[        R                  5      (       a  [	        U5      nU R                  5       R                  [        R                  " U R                  5      R                  U5      5      R                  5       $ )ax  
Raise to the power of the given exponent.

If the exponent is float, the result follows the dtype of exponent.
Otherwise, it follows dtype of base.

Parameters
----------
exponent
    The exponent. Accepts Series input.

Examples
--------
Raising integers to positive integers results in integers:

>>> s = pl.Series("foo", [1, 2, 3, 4])
>>> s.pow(3)
shape: (4,)
Series: 'foo' [i64]
[
    1
    8
    27
    64
]

In order to raise integers to negative integers, you can cast either the
base or the exponent to float:

>>> s.pow(-3.0)
shape: (4,)
Series: 'foo' [f64]
[
        1.0
        0.125
        0.037037
        0.015625
]
)rM   r   r   r   r   r  r  r=  r  r   r#  r  r$  s     r   r#  
Series.pow8  sb    P H%%*Xrzz*J*Jh'H}}))!%%		*:*>*>x*HISSUUr   c                6    U R                   R                  5       $ )zj
Get the minimal value in this Series.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3])
>>> s.min()
1
)r   minr   s    r   r  
Series.mind       ww{{}r   c                6    U R                   R                  5       $ )zj
Get the maximum value in this Series.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3])
>>> s.max()
3
)r   maxr   s    r   r  
Series.maxp  r  r   c                    U R                  5       R                  [        R                  " U R                  5      R                  5       5      R                  5       $ )aI  
Get maximum value, but propagate/poison encountered NaN values.

This differs from numpy's `nanmax` as numpy defaults to propagating NaN values,
whereas polars defaults to ignoring them.

Examples
--------
>>> s = pl.Series("a", [1, 3, 4])
>>> s.nan_max()
4

>>> s = pl.Series("a", [1.0, float("nan"), 4.0])
>>> s.nan_max()
nan
)r  r  r=  r  r   nan_maxrK  r   s    r   r  Series.nan_max|  :    " }}))!%%		*:*B*B*DEJJLLr   c                    U R                  5       R                  [        R                  " U R                  5      R                  5       5      R                  5       $ )aI  
Get minimum value, but propagate/poison encountered NaN values.

This differs from numpy's `nanmax` as numpy defaults to propagating NaN values,
whereas polars defaults to ignoring them.

Examples
--------
>>> s = pl.Series("a", [1, 3, 4])
>>> s.nan_min()
1

>>> s = pl.Series("a", [1.0, float("nan"), 4.0])
>>> s.nan_min()
nan
)r  r  r=  r  r   nan_minrK  r   s    r   r  Series.nan_min  r   r   r%  c                8    U R                   R                  U5      $ )u+  
Get the standard deviation of this Series.

Parameters
----------
ddof
    “Delta Degrees of Freedom”: the divisor used in the calculation is N - ddof,
    where N represents the number of elements.
    By default ddof is 1.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3])
>>> s.std()
1.0
)r   stdr   ddofs     r   r  
Series.std      " ww{{4  r   c                8    U R                   R                  U5      $ )u  
Get variance of this Series.

Parameters
----------
ddof
    “Delta Degrees of Freedom”: the divisor used in the calculation is N - ddof,
    where N represents the number of elements.
    By default ddof is 1.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3])
>>> s.var()
1.0
)r   varr  s     r   r  
Series.var  r	  r   c                6    U R                   R                  5       $ )zh
Get the median of this Series.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3])
>>> s.median()
2.0
)r   medianr   s    r   r  Series.median  s     ww~~r   c                8    U R                   R                  X5      $ )a&  
Get the quantile value of this Series.

Parameters
----------
quantile
    Quantile between 0.0 and 1.0.
interpolation : {'nearest', 'higher', 'lower', 'midpoint', 'linear', 'equiprobable'}
    Interpolation method.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3])
>>> s.quantile(0.5)
2.0
)r   quantile)r   r  r  s      r   r  Series.quantile  s    & ww88r   _)	separator
drop_firstr  c               L    [        U R                  R                  XU5      5      $ )u  
Get dummy/indicator variables.

Parameters
----------
separator
    Separator/delimiter used when generating column names.
drop_first
    Remove the first category from the variable being encoded.
drop_nulls
    If there are `None` values in the series, a `null` column is not generated

Examples
--------
>>> s = pl.Series("a", [1, 2, 3])
>>> s.to_dummies()
shape: (3, 3)
┌─────┬─────┬─────┐
│ a_1 ┆ a_2 ┆ a_3 │
│ --- ┆ --- ┆ --- │
│ u8  ┆ u8  ┆ u8  │
╞═════╪═════╪═════╡
│ 1   ┆ 0   ┆ 0   │
│ 0   ┆ 1   ┆ 0   │
│ 0   ┆ 0   ┆ 1   │
└─────┴─────┴─────┘

>>> s.to_dummies(drop_first=True)
shape: (3, 2)
┌─────┬─────┐
│ a_2 ┆ a_3 │
│ --- ┆ --- │
│ u8  ┆ u8  │
╞═════╪═════╡
│ 0   ┆ 0   │
│ 1   ┆ 0   │
│ 0   ┆ 1   │
└─────┴─────┘
)r/   r   
to_dummies)r   r  r  r  s       r   r  Series.to_dummies  s!    \ tww)))LMMr   )labelsleft_closedinclude_breaksc                   g)u{  
Bin continuous values into discrete categories.

.. warning::
    This functionality is considered **unstable**. It may be changed
    at any point without it being considered a breaking change.

Parameters
----------
breaks
    List of unique cut points.
labels
    Names of the categories. The number of labels must be equal to the number
    of cut points plus one.
left_closed
    Set the intervals to be left-closed instead of right-closed.
include_breaks
    Include a column with the right endpoint of the bin each observation falls
    in. This will change the data type of the output from a
    :class:`Categorical` to a :class:`Struct`.

Returns
-------
Series
    Series of data type :class:`Categorical` if `include_breaks` is set to
    `False` (default), otherwise a Series of data type :class:`Struct`.

See Also
--------
qcut

Examples
--------
Divide the column into three categories.

>>> s = pl.Series("foo", [-2, -1, 0, 1, 2])
>>> s.cut([-1, 1], labels=["a", "b", "c"])
shape: (5,)
Series: 'foo' [cat]
[
        "a"
        "a"
        "b"
        "b"
        "c"
]

Create a DataFrame with the breakpoint and category for each value.

>>> cut = s.cut([-1, 1], include_breaks=True).alias("cut")
>>> s.to_frame().with_columns(cut).unnest("cut")
shape: (5, 3)
┌─────┬────────────┬────────────┐
│ foo ┆ breakpoint ┆ category   │
│ --- ┆ ---        ┆ ---        │
│ i64 ┆ f64        ┆ cat        │
╞═════╪════════════╪════════════╡
│ -2  ┆ -1.0       ┆ (-inf, -1] │
│ -1  ┆ -1.0       ┆ (-inf, -1] │
│ 0   ┆ 1.0        ┆ (-1, 1]    │
│ 1   ┆ 1.0        ┆ (-1, 1]    │
│ 2   ┆ inf        ┆ (1, inf]   │
└─────┴────────────┴────────────┘
Nr  )r   breaksr  r  r  s        r   cut
Series.cut	  r  r   )r  r  allow_duplicatesr  c                   g)u
  
Bin continuous values into discrete categories based on their quantiles.

.. warning::
    This functionality is considered **unstable**. It may be changed
    at any point without it being considered a breaking change.

Parameters
----------
quantiles
    Either a list of quantile probabilities between 0 and 1 or a positive
    integer determining the number of bins with uniform probability.
labels
    Names of the categories. The number of labels must be equal to the number
    of cut points plus one.
left_closed
    Set the intervals to be left-closed instead of right-closed.
allow_duplicates
    If set to `True`, duplicates in the resulting quantiles are dropped,
    rather than raising a `DuplicateError`. This can happen even with unique
    probabilities, depending on the data.
include_breaks
    Include a column with the right endpoint of the bin each observation falls
    in. This will change the data type of the output from a
    :class:`Categorical` to a :class:`Struct`.

Returns
-------
Series
    Series of data type :class:`Categorical` if `include_breaks` is set to
    `False` (default), otherwise a Series of data type :class:`Struct`.

See Also
--------
cut

Examples
--------
Divide a column into three categories according to pre-defined quantile
probabilities.

>>> s = pl.Series("foo", [-2, -1, 0, 1, 2])
>>> s.qcut([0.25, 0.75], labels=["a", "b", "c"])
shape: (5,)
Series: 'foo' [cat]
[
        "a"
        "a"
        "b"
        "b"
        "c"
]

Divide a column into two categories using uniform quantile probabilities.

>>> s.qcut(2, labels=["low", "high"], left_closed=True)
shape: (5,)
Series: 'foo' [cat]
[
        "low"
        "low"
        "high"
        "high"
        "high"
]

Create a DataFrame with the breakpoint and category for each value.

>>> cut = s.qcut([0.25, 0.75], include_breaks=True).alias("cut")
>>> s.to_frame().with_columns(cut).unnest("cut")
shape: (5, 3)
┌─────┬────────────┬────────────┐
│ foo ┆ breakpoint ┆ category   │
│ --- ┆ ---        ┆ ---        │
│ i64 ┆ f64        ┆ cat        │
╞═════╪════════════╪════════════╡
│ -2  ┆ -1.0       ┆ (-inf, -1] │
│ -1  ┆ -1.0       ┆ (-inf, -1] │
│ 0   ┆ 1.0        ┆ (-1, 1]    │
│ 1   ┆ 1.0        ┆ (-1, 1]    │
│ 2   ┆ inf        ┆ (1, inf]   │
└─────┴────────────┴────────────┘
Nr  )r   	quantilesr  r  r   r  s         r   qcutSeries.qcutc	  r  r   c                    g)u  
Compress the Series data using run-length encoding.

Run-length encoding (RLE) encodes data by storing each *run* of identical values
as a single value and its length.

Returns
-------
Series
    Series of data type `Struct` with fields `len` of data type `UInt32`
    and `value` of the original data type.

Examples
--------
>>> s = pl.Series("s", [1, 1, 2, 1, None, 1, 3, 3])
>>> s.rle().struct.unnest()
shape: (6, 2)
┌─────┬───────┐
│ len ┆ value │
│ --- ┆ ---   │
│ u32 ┆ i64   │
╞═════╪═══════╡
│ 2   ┆ 1     │
│ 1   ┆ 2     │
│ 1   ┆ 1     │
│ 1   ┆ null  │
│ 1   ┆ 1     │
│ 2   ┆ 3     │
└─────┴───────┘
Nr  r   s    r   rle
Series.rle	  r  r   c                    g)a6  
Get a distinct integer ID for each run of identical values.

The ID starts at 0 and increases by one each time the value of the column
changes.

Returns
-------
Series
    Series of data type `UInt32`.

See Also
--------
rle

Notes
-----
This functionality is especially useful for defining a new group for every time
a column's value changes, rather than for every distinct value of that column.

Examples
--------
>>> s = pl.Series("s", [1, 1, 2, 1, None, 1, 3, 3])
>>> s.rle_id()
shape: (8,)
Series: 's' [u32]
[
    0
    0
    1
    2
    3
    4
    5
    5
]
Nr  r   s    r   rle_idSeries.rle_id	  r  r   )	bin_countinclude_categoryinclude_breakpointc          	     (   U R                  5       R                  [        R                  " U R                  5      R                  UUUUS95      R                  5       nU(       d  U(       d  UR                  5       $ UR                  R                  5       $ )u=  
Bin values into buckets and count their occurrences.

.. warning::
    This functionality is considered **unstable**. It may be changed
    at any point without it being considered a breaking change.

Parameters
----------
bins
    Bin edges. If None given, we determine the edges based on the data.
bin_count
    If `bins` is not provided, `bin_count` uniform bins are created that fully
    encompass the data.
include_breakpoint
    Include a column that indicates the upper breakpoint.
include_category
    Include a column that shows the intervals as categories.

Returns
-------
DataFrame

Examples
--------
>>> a = pl.Series("a", [1, 3, 8, 8, 2, 1, 3])
>>> a.hist(bin_count=4)
shape: (4, 3)
┌────────────┬─────────────┬───────┐
│ breakpoint ┆ category    ┆ count │
│ ---        ┆ ---         ┆ ---   │
│ f64        ┆ cat         ┆ u32   │
╞════════════╪═════════════╪═══════╡
│ 2.75       ┆ [1.0, 2.75] ┆ 3     │
│ 4.5        ┆ (2.75, 4.5] ┆ 2     │
│ 6.25       ┆ (4.5, 6.25] ┆ 0     │
│ 8.0        ┆ (6.25, 8.0] ┆ 2     │
└────────────┴─────────────┴───────┘
)binsr+  r,  r-  )	r  r  r=  r  r   histr  r   unnest)r   r/  r+  r,  r-  r  s         r   r0  Series.hist
  sy    b MMOZdii %%'%5'9	 &  Y[ 	 "*:<<>!::$$&&r   sortparallelr   	normalizec          	         U=(       d    U(       a  SOSn[         R                  R                  U R                  R	                  XX4S95      $ )u  
Count the occurrences of unique values.

Parameters
----------
sort
    Sort the output by count, in descending order.
    If set to `False` (default), the order is non-deterministic.
parallel
    Execute the computation in parallel.

    .. note::
        This option should likely *not* be enabled in a `group_by` context,
        as the computation will already be parallelized per group.
name
    Give the resulting count column a specific name; if `normalize` is
    True this defaults to "proportion", otherwise defaults to "count".
normalize
    If True, the count is returned as the relative frequency of unique
    values normalized to 1.0.

Returns
-------
DataFrame
    Columns map the unique values to their count (or proportion).

Examples
--------
>>> s = pl.Series("color", ["red", "blue", "red", "green", "blue", "blue"])
>>> s.value_counts()  # doctest: +IGNORE_RESULT
shape: (3, 2)
┌───────┬───────┐
│ color ┆ count │
│ ---   ┆ ---   │
│ str   ┆ u32   │
╞═══════╪═══════╡
│ red   ┆ 2     │
│ green ┆ 1     │
│ blue  ┆ 3     │
└───────┴───────┘

Sort the output by count and customize the count column name.

>>> s.value_counts(sort=True, name="n")
shape: (3, 2)
┌───────┬─────┐
│ color ┆ n   │
│ ---   ┆ --- │
│ str   ┆ u32 │
╞═══════╪═════╡
│ blue  ┆ 3   │
│ red   ┆ 2   │
│ green ┆ 1   │
└───────┴─────┘

Return the count as a relative frequency, normalized to 1.0:

>>> s.value_counts(sort=True, normalize=True, name="fraction")
shape: (3, 2)
┌───────┬──────────┐
│ color ┆ fraction │
│ ---   ┆ ---      │
│ str   ┆ f64      │
╞═══════╪══════════╡
│ blue  ┆ 0.5      │
│ red   ┆ 0.333333 │
│ green ┆ 0.166667 │
└───────┴──────────┘

proportioncountr3  )r   rq   
_from_pydfr   value_counts)r   r4  r5  r   r6  s        r   r;  Series.value_countsI
  sF    Z ?	w||&&GG  4 ! 
 	
r   c                    g)z
Return a count of the unique values in the order of appearance.

Examples
--------
>>> s = pl.Series("id", ["a", "b", "b", "c", "c", "c"])
>>> s.unique_counts()
shape: (3,)
Series: 'id' [u32]
[
    1
    2
    3
]
Nr  r   s    r   unique_countsSeries.unique_counts
  r  r   r6  c                   U R                  5       R                  [        R                  " U R                  5      R                  XS95      R                  5       R                  5       $ )a  
Computes the entropy.

Uses the formula `-sum(pk * log(pk))` where `pk` are discrete probabilities.

Parameters
----------
base
    Given base, defaults to `e`
normalize
    Normalize pk if it doesn't sum to 1.

Examples
--------
>>> a = pl.Series([0.99, 0.005, 0.005])
>>> a.entropy(normalize=True)
0.06293300616044681
>>> b = pl.Series([0.65, 0.10, 0.25])
>>> b.entropy(normalize=True)
0.8568409950394724
r@  )r  r  r=  r  r   entropyr  rK  )r   r  r6  s      r   rB  Series.entropy
  sE    . MMOZdii(000KLY[TV		
r   min_periodsmin_samplesz1.21.0version)rE  r5  c                   g)a  
Run an expression over a sliding window that increases `1` slot every iteration.

.. warning::
    This functionality is considered **unstable**. It may be changed
    at any point without it being considered a breaking change.

.. versionchanged:: 1.21.0
    The `min_periods` parameter was renamed `min_samples`.

Parameters
----------
expr
    Expression to evaluate
min_samples
    Number of valid values there should be in the window before the expression
    is evaluated. valid values = `length - null_count`
parallel
    Run in parallel. Don't do this in a group by or another operation that
    already has much parallelization.

Warnings
--------
This can be really slow as it can have `O(n^2)` complexity. Don't use this
for operations that visit all elements.

Examples
--------
>>> s = pl.Series("values", [1, 2, 3, 4, 5])
>>> s.cumulative_eval(pl.element().first() - pl.element().last() ** 2)
shape: (5,)
Series: 'values' [i64]
[
    0
    -3
    -8
    -15
    -24
]
Nr  )r   exprrE  r5  s       r   cumulative_evalSeries.cumulative_eval
  r  r   c                \    U R                  5       nUR                  R                  U5        U$ )z
Rename the series.

Parameters
----------
name
    The new name.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3])
>>> s.alias("b")
shape: (3,)
Series: 'b' [i64]
[
        1
        2
        3
]
)rf  r   r  )r   r   r   s      r   r)  Series.alias
  s$    * JJL	Dr   c                $    U R                  U5      $ )z
Rename this Series.

Alias for :func:`Series.alias`.

Parameters
----------
name
    New name.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3])
>>> s.rename("b")
shape: (3,)
Series: 'b' [i64]
[
        1
        2
        3
]
)r)  r  s     r   r  Series.rename  s    . zz$r   c                6    U R                   R                  5       $ )aK  
Get the length of each individual chunk.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3])
>>> s2 = pl.Series("a", [4, 5, 6])

Concatenate Series with rechunk = True

>>> pl.concat([s, s2], rechunk=True).chunk_lengths()
[6]

Concatenate Series with rechunk = False

>>> pl.concat([s, s2], rechunk=False).chunk_lengths()
[3, 3]
)r   chunk_lengthsr   s    r   rQ  Series.chunk_lengths+  s    & ww$$&&r   c                6    U R                   R                  5       $ )aX  
Get the number of chunks that this Series contains.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3])
>>> s.n_chunks()
1
>>> s2 = pl.Series("a", [4, 5, 6])

Concatenate Series with rechunk = True

>>> pl.concat([s, s2], rechunk=True).n_chunks()
1

Concatenate Series with rechunk = False

>>> pl.concat([s, s2], rechunk=False).n_chunks()
2
)r   r  r   s    r   r  Series.n_chunks@  s    * ww!!r   )reversec                   g)z
Get an array with the cumulative max computed at every element.

Parameters
----------
reverse
    reverse the operation.

Examples
--------
>>> s = pl.Series("s", [3, 5, 1])
>>> s.cum_max()
shape: (3,)
Series: 's' [i64]
[
    3
    5
    5
]
Nr  r   rU  s     r   cum_maxSeries.cum_maxW  r  r   c                   g)z
Get an array with the cumulative min computed at every element.

Parameters
----------
reverse
    reverse the operation.

Examples
--------
>>> s = pl.Series("s", [1, 2, 3])
>>> s.cum_min()
shape: (3,)
Series: 's' [i64]
[
    1
    1
    1
]
Nr  rW  s     r   cum_minSeries.cum_minm  r  r   c                   g)aj  
Get an array with the cumulative product computed at every element.

Parameters
----------
reverse
    reverse the operation.

Notes
-----
Dtypes in {Int8, UInt8, Int16, UInt16} are cast to
Int64 before summing to prevent overflow issues.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3])
>>> s.cum_prod()
shape: (3,)
Series: 'a' [i64]
[
    1
    2
    6
]
Nr  rW  s     r   cum_prodSeries.cum_prod  r  r   c                   g)ae  
Get an array with the cumulative sum computed at every element.

Parameters
----------
reverse
    reverse the operation.

Notes
-----
Dtypes in {Int8, UInt8, Int16, UInt16} are cast to
Int64 before summing to prevent overflow issues.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3])
>>> s.cum_sum()
shape: (3,)
Series: 'a' [i64]
[
    1
    3
    6
]
Nr  rW  s     r   cum_sumSeries.cum_sum  r  r   c                   g)a  
Return the cumulative count of the non-null values in the column.

Parameters
----------
reverse
    Reverse the operation.

Examples
--------
>>> s = pl.Series(["x", "k", None, "d"])
>>> s.cum_count()
shape: (4,)
Series: '' [u32]
[
        1
        2
        2
        3
]
Nr  rW  s     r   	cum_countSeries.cum_count  r  r   c                R    U R                  U R                  R                  XS95      $ )aT  
Get a slice of this Series.

Parameters
----------
offset
    Start index. Negative indexing is supported.
length
    Length of the slice. If set to `None`, all rows starting at the offset
    will be selected.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3, 4])
>>> s.slice(1, 2)
shape: (2,)
Series: 'a' [i64]
[
        2
        3
]
)rU  length)r   r   rQ  )r   rU  rg  s      r   rQ  Series.slice  s$    . ""477===#NOOr   c                f    [        X5        U R                  R                  UR                  5        U $ )a  
Append a Series to this one.

The resulting series will consist of multiple chunks.

Parameters
----------
other
    Series to append.

Warnings
--------
This method modifies the series in-place. The series is returned for
convenience only.

See Also
--------
extend

Examples
--------
>>> a = pl.Series("a", [1, 2, 3])
>>> b = pl.Series("b", [4, 5])
>>> a.append(b)
shape: (5,)
Series: 'a' [i64]
[
    1
    2
    3
    4
    5
]

The resulting series will consist of multiple chunks.

>>> a.n_chunks()
2
)r+   r   r  r5  s     r   r  Series.append  s&    P 	$&uxx r   c                f    [        X5        U R                  R                  UR                  5        U $ )a
  
Extend the memory backed by this Series with the values from another.

Different from `append`, which adds the chunks from `other` to the chunks of
this series, `extend` appends the data from `other` to the underlying memory
locations and thus may cause a reallocation (which is expensive).

If this does `not` cause a reallocation, the resulting data structure will not
have any extra chunks and thus will yield faster queries.

Prefer `extend` over `append` when you want to do a query after a single
append. For instance, during online operations where you add `n` rows
and rerun a query.

Prefer `append` over `extend` when you want to append many times
before doing a query. For instance, when you read in multiple files and want
to store them in a single `Series`. In the latter case, finish the sequence
of `append` operations with a `rechunk`.

Parameters
----------
other
    Series to extend the series with.

Warnings
--------
This method modifies the series in-place. The series is returned for
convenience only.

See Also
--------
append

Examples
--------
>>> a = pl.Series("a", [1, 2, 3])
>>> b = pl.Series("b", [4, 5])
>>> a.extend(b)
shape: (5,)
Series: 'a' [i64]
[
    1
    2
    3
    4
    5
]

The resulting series will consist of a single chunk.

>>> a.n_chunks()
1
)r+   r   extendr5  s     r   rl  Series.extend  s&    l 	$&uxx r   c                    [        U[        5      (       d  [        SU5      nU R                  U R                  R	                  UR                  5      5      $ )a  
Filter elements by a boolean mask.

The original order of the remaining elements is preserved.

Elements where the filter does not evaluate to True are discarded, including
nulls.

Parameters
----------
predicate
    Boolean mask.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3])
>>> mask = pl.Series("", [True, False, True])
>>> s.filter(mask)
shape: (2,)
Series: 'a' [i64]
[
        1
        3
]
r   )r   r   r   r   r  )r   	predicates     r   r  Series.filterO  s?    4 )V,,r9-I""477>>),,#?@@r   c                    US:  a  [        SU R                  5       U-   5      nU R                  U R                  R	                  U5      5      $ )a  
Get the first `n` elements.

Parameters
----------
n
    Number of elements to return. If a negative value is passed, return all
    elements except the last `abs(n)`.

See Also
--------
tail, slice

Examples
--------
>>> s = pl.Series("a", [1, 2, 3, 4, 5])
>>> s.head(3)
shape: (3,)
Series: 'a' [i64]
[
        1
        2
        3
]

Pass a negative value to get all rows `except` the last `abs(n)`.

>>> s.head(-3)
shape: (2,)
Series: 'a' [i64]
[
        1
        2
]
r   )r  r  r   r   headr   ns     r   rr  Series.headm  ?    H q5AtxxzA~&A""477<<?33r   c                    US:  a  [        SU R                  5       U-   5      nU R                  U R                  R	                  U5      5      $ )a  
Get the last `n` elements.

Parameters
----------
n
    Number of elements to return. If a negative value is passed, return all
    elements except the first `abs(n)`.

See Also
--------
head, slice

Examples
--------
>>> s = pl.Series("a", [1, 2, 3, 4, 5])
>>> s.tail(3)
shape: (3,)
Series: 'a' [i64]
[
        3
        4
        5
]

Pass a negative value to get all rows `except` the first `abs(n)`.

>>> s.tail(-3)
shape: (2,)
Series: 'a' [i64]
[
        4
        5
]
r   )r  r  r   r   tailrs  s     r   rx  Series.tail  rv  r   c                $    U R                  U5      $ )a  
Get the first `n` elements.

Alias for :func:`Series.head`.

Parameters
----------
n
    Number of elements to return. If a negative value is passed, return all
    elements except the last `abs(n)`.

See Also
--------
head

Examples
--------
>>> s = pl.Series("a", [1, 2, 3, 4, 5])
>>> s.limit(3)
shape: (3,)
Series: 'a' [i64]
[
    1
    2
    3
]

Pass a negative value to get all rows `except` the last `abs(n)`.

>>> s.limit(-3)
shape: (2,)
Series: 'a' [i64]
[
        1
        2
]
)rr  rs  s     r   limitSeries.limit  s    L yy|r   c                    g)am  
Take every nth value in the Series and return as new Series.

Parameters
----------
n
    Gather every *n*-th row.
offset
    Start the row index at this offset.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3, 4])
>>> s.gather_every(2)
shape: (2,)
Series: 'a' [i64]
[
    1
    3
]
>>> s.gather_every(2, offset=1)
shape: (2,)
Series: 'a' [i64]
[
    2
    4
]
Nr  )r   rt  rU  s      r   gather_everySeries.gather_every  r  r   )
descending
nulls_lastmultithreadedrw  c                   U(       a#  U R                   R                  XU5      U l         U $ U R                  U R                   R                  XU5      5      $ )a  
Sort this Series.

Parameters
----------
descending
    Sort in descending order.
nulls_last
    Place null values last instead of first.
multithreaded
    Sort using multiple threads.
in_place
    Sort in-place.

Examples
--------
>>> s = pl.Series("a", [1, 3, 4, 2])
>>> s.sort()
shape: (4,)
Series: 'a' [i64]
[
        1
        2
        3
        4
]
>>> s.sort(descending=True)
shape: (4,)
Series: 'a' [i64]
[
        4
        3
        2
        1
]
)r   r4  r   )r   r  r  r  rw  s        r   r4  Series.sort  sH    X ggll:=IDGK&&Z]C r   c                    g)a  
Return the `k` largest elements.

Non-null elements are always preferred over null elements. The output is
not guaranteed to be in any particular order, call :func:`sort` after
this function if you wish the output to be sorted.

This has time complexity:

.. math:: O(n)

Parameters
----------
k
    Number of elements to return.

See Also
--------
top_k_by
bottom_k
bottom_k_by

Examples
--------
>>> s = pl.Series("a", [2, 5, 1, 4, 3])
>>> s.top_k(3)
shape: (3,)
Series: 'a' [i64]
[
    5
    4
    3
]
Nr  r   r   s     r   top_kSeries.top_k7  r  r   c                   g)ad  
Return the `k` largest elements of the `by` column.

Non-null elements are always preferred over null elements, regardless of
the value of `reverse`. The output is not guaranteed to be in any
particular order, call :func:`sort` after this function if you wish the
output to be sorted.

This has time complexity:

.. math:: O(n \log{n})

Parameters
----------
by
    Column used to determine the largest elements.
    Accepts expression input. Strings are parsed as column names.
k
    Number of elements to return.
reverse
    Consider the `k` smallest elements of the `by` column (instead of the `k`
    largest). This can be specified per column by passing a sequence of
    booleans.

See Also
--------
top_k
bottom_k
bottom_k_by

Examples
--------
>>> s = pl.Series("a", [2, 5, 1, 4, 3])
>>> s.top_k_by("a", 3)
shape: (3,)
Series: 'a' [i64]
[
    5
    4
    3
]
Nr  r   byr   rU  s       r   top_k_bySeries.top_k_by[  r  r   c                    g)a  
Return the `k` smallest elements.

Non-null elements are always preferred over null elements. The output is
not guaranteed to be in any particular order, call :func:`sort` after
this function if you wish the output to be sorted.

This has time complexity:

.. math:: O(n)

Parameters
----------
k
    Number of elements to return.

See Also
--------
top_k
top_k_by
bottom_k_by

Examples
--------
>>> s = pl.Series("a", [2, 5, 1, 4, 3])
>>> s.bottom_k(3)
shape: (3,)
Series: 'a' [i64]
[
    1
    2
    3
]
Nr  r  s     r   bottom_kSeries.bottom_k  r  r   c                   g)ag  
Return the `k` smallest elements of the `by` column.

Non-null elements are always preferred over null elements, regardless of
the value of `reverse`. The output is not guaranteed to be in any
particular order, call :func:`sort` after this function if you wish the
output to be sorted.

This has time complexity:

.. math:: O(n \log{n})

Parameters
----------
by
    Column used to determine the smallest elements.
    Accepts expression input. Strings are parsed as column names.
k
    Number of elements to return.
reverse
    Consider the `k` largest elements of the `by` column( (instead of the `k`
    smallest). This can be specified per column by passing a sequence of
    booleans.

See Also
--------
top_k
top_k_by
bottom_k

Examples
--------
>>> s = pl.Series("a", [2, 5, 1, 4, 3])
>>> s.bottom_k_by("a", 3)
shape: (3,)
Series: 'a' [i64]
[
    1
    2
    3
]
Nr  r  s       r   bottom_k_bySeries.bottom_k_by  r  r   )r  r  c                   g)a  
Get the index values that would sort this Series.

Parameters
----------
descending
    Sort in descending order.
nulls_last
    Place null values last instead of first.

See Also
--------
Series.gather: Take values by index.
Series.rank : Get the rank of each row.

Examples
--------
>>> s = pl.Series("a", [5, 3, 4, 1, 2])
>>> s.arg_sort()
shape: (5,)
Series: 'a' [u32]
[
    3
    4
    1
    2
    0
]
Nr  r   r  r  s      r   arg_sortSeries.arg_sort  r  r   c                    g)z
Get unique index as Series.

Returns
-------
Series

Examples
--------
>>> s = pl.Series("a", [1, 2, 2, 3])
>>> s.arg_unique()
shape: (3,)
Series: 'a' [u32]
[
        0
        1
        3
]
Nr  r   s    r   
arg_uniqueSeries.arg_unique  r  r   c                6    U R                   R                  5       $ )z
Get the index of the minimal value.

Returns
-------
int

Examples
--------
>>> s = pl.Series("a", [3, 2, 1])
>>> s.arg_min()
2
)r   arg_minr   s    r   r  Series.arg_min       ww  r   c                6    U R                   R                  5       $ )z
Get the index of the maximal value.

Returns
-------
int

Examples
--------
>>> s = pl.Series("a", [3, 2, 1])
>>> s.arg_max()
0
)r   arg_maxr   s    r   r  Series.arg_max'  r  r   r  c                   g r   r  r   elementsider  s       r   search_sortedSeries.search_sorted7  s     r   c                   g r   r  r  s       r   r  r  @  s     r   c                  [         R                  " [         R                  " U 5      R                  XUS95      n[	        U[
        [        [        R                  45      (       a  UR                  5       $ [        U5      (       a/  [	        U[        R                  5      (       a  UR                  5       $ UR                  5       $ )a  
Find indices where elements should be inserted to maintain order.

.. math:: a[i-1] < v <= a[i]

Parameters
----------
element
    Expression or scalar value.
side : {'any', 'left', 'right'}
    If 'any', the index of the first suitable location found is given.
    If 'left', the index of the leftmost suitable location found is given.
    If 'right', return the rightmost suitable location found is given.
descending
    Boolean indicating whether the values are descending or not (they
    are required to be sorted either way).

Examples
--------
>>> s = pl.Series("set", [1, 2, 3, 4, 4, 5, 6, 7])
>>> s.search_sorted(4)
3
>>> s.search_sorted(4, "left")
3
>>> s.search_sorted(4, "right")
5
>>> s.search_sorted([1, 4, 5])
shape: (3,)
Series: 'set' [u32]
[
        0
        3
        5
]
>>> s.search_sorted([1, 4, 5], "left")
shape: (3,)
Series: 'set' [u32]
[
        0
        3
        5
]
>>> s.search_sorted([1, 4, 5], "right")
shape: (3,)
Series: 'set' [u32]
[
        1
        5
        6
]
r  )r=  r  r>  r  r   r   r   r   rs   r  rM   r   r   rK  )r   r  r  r  dfs        r   r  r  I  s    t XXaeeDk//*/UVgfbgg677<<>!g&&:grzz+J+J<<>!779r   )maintain_orderc                   g)z
Get unique elements in series.

Parameters
----------
maintain_order
    Maintain order of data. This requires more work.

Examples
--------
>>> s = pl.Series("a", [1, 2, 2, 3])
>>> s.unique().sort()
shape: (3,)
Series: 'a' [i64]
[
    1
    2
    3
]
Nr  )r   r  s     r   uniqueSeries.unique  r  r   c                    g)z
Take values by index.

Parameters
----------
indices
    Index location used for selection.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3, 4])
>>> s.gather([1, 3])
shape: (2,)
Series: 'a' [i64]
[
        2
        4
]
Nr  )r   indicess     r   gatherSeries.gather  r  r   c                6    U R                   R                  5       $ )zr
Count the null values in this Series.

Examples
--------
>>> s = pl.Series([1, None, None])
>>> s.null_count()
2
)r   
null_countr   s    r   r  Series.null_count  s     ww!!##r   c                6    U R                   R                  5       $ )z
Check whether the Series contains one or more null values.

Examples
--------
>>> s = pl.Series([1, 2, None])
>>> s.has_nulls()
True
>>> s[:2].has_nulls()
False
r   rH  r   s    r   rH  Series.has_nulls  s     ww  ""r   z_`has_validity` is deprecated; use `has_nulls` instead to check for the presence of null values.c                6    U R                   R                  5       $ )z
Check whether the Series contains one or more null values.

.. deprecated:: 0.20.30
    Use the :meth:`has_nulls` method instead.
r  r   s    r   has_validitySeries.has_validity  s     ww  ""r   c                (    U R                  5       S:H  $ )zu
Check if the Series is empty.

Examples
--------
>>> s = pl.Series("a", [], dtype=pl.Float32)
>>> s.is_empty()
True
r   r0  r   s    r   is_emptySeries.is_empty  s     xxzQr   c               8    U R                   R                  X5      $ )aG  
Check if the Series is sorted.

Parameters
----------
descending
    Check if the Series is sorted in descending order
nulls_last
    Set nulls at the end of the Series in sorted check.

Examples
--------
>>> s = pl.Series([1, 3, 2])
>>> s.is_sorted()
False

>>> s = pl.Series([3, 2, 1])
>>> s.is_sorted(descending=True)
True
)r   	is_sortedr  s      r   r  Series.is_sorted  s    * ww  88r   c                T    U R                  U R                  R                  5       5      $ )z
Negate a boolean Series.

Returns
-------
Series
    Series of data type :class:`Boolean`.

Examples
--------
>>> s = pl.Series("a", [True, False, False])
>>> s.not_()
shape: (3,)
Series: 'a' [bool]
[
    false
    true
    true
]
)r   r   r  r   s    r   r  Series.not_  s    * ""477<<>22r   c                    g)a  
Returns a boolean Series indicating which values are null.

Returns
-------
Series
    Series of data type :class:`Boolean`.

Examples
--------
>>> s = pl.Series("a", [1.0, 2.0, 3.0, None])
>>> s.is_null()
shape: (4,)
Series: 'a' [bool]
[
    false
    false
    false
    true
]
Nr  r   s    r   is_nullSeries.is_null  r  r   c                    g)a  
Returns a boolean Series indicating which values are not null.

Returns
-------
Series
    Series of data type :class:`Boolean`.

Examples
--------
>>> s = pl.Series("a", [1.0, 2.0, 3.0, None])
>>> s.is_not_null()
shape: (4,)
Series: 'a' [bool]
[
    true
    true
    true
    false
]
Nr  r   s    r   r  Series.is_not_null0  r  r   c                    g)a2  
Returns a boolean Series indicating which values are finite.

Returns
-------
Series
    Series of data type :class:`Boolean`.

Examples
--------
>>> import numpy as np
>>> s = pl.Series("a", [1.0, 2.0, np.inf])
>>> s.is_finite()
shape: (3,)
Series: 'a' [bool]
[
        true
        true
        false
]
Nr  r   s    r   	is_finiteSeries.is_finiteG  r  r   c                    g)a7  
Returns a boolean Series indicating which values are infinite.

Returns
-------
Series
    Series of data type :class:`Boolean`.

Examples
--------
>>> import numpy as np
>>> s = pl.Series("a", [1.0, 2.0, np.inf])
>>> s.is_infinite()
shape: (3,)
Series: 'a' [bool]
[
        false
        false
        true
]
Nr  r   s    r   is_infiniteSeries.is_infinite^  r  r   c                    g)a@  
Returns a boolean Series indicating which values are NaN.

Returns
-------
Series
    Series of data type :class:`Boolean`.

Examples
--------
>>> import numpy as np
>>> s = pl.Series("a", [1.0, 2.0, 3.0, np.nan])
>>> s.is_nan()
shape: (4,)
Series: 'a' [bool]
[
        false
        false
        false
        true
]
Nr  r   s    r   is_nanSeries.is_nanu  r  r   c                    g)aF  
Returns a boolean Series indicating which values are not NaN.

Returns
-------
Series
    Series of data type :class:`Boolean`.

Examples
--------
>>> import numpy as np
>>> s = pl.Series("a", [1.0, 2.0, 3.0, np.nan])
>>> s.is_not_nan()
shape: (4,)
Series: 'a' [bool]
[
        true
        true
        true
        false
]
Nr  r   s    r   
is_not_nanSeries.is_not_nan  r  r   )nulls_equalc                   g)aF  
Check if elements of this Series are in the other Series.

Parameters
----------
nulls_equal : bool, default False
    If True, treat null as a distinct value. Null values will not propagate.

Returns
-------
Series
    Series of data type :class:`Boolean`.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3])
>>> s2 = pl.Series("b", [2, 4, None])
>>> s2.is_in(s)
shape: (3,)
Series: 'b' [bool]
[
        true
        false
        null
]
>>> # when nulls_equal=True, None is treated as a distinct value
>>> s2.is_in(s, nulls_equal=True)
shape: (3,)
Series: 'b' [bool]
[
        true
        false
        false
]

>>> # check if some values are a member of sublists
>>> sets = pl.Series("sets", [[1, 2, 3], [1, 2], [9, 10]])
>>> optional_members = pl.Series("optional_members", [1, 2, 3])
>>> print(sets)
shape: (3,)
Series: 'sets' [list[i64]]
[
    [1, 2, 3]
    [1, 2]
    [9, 10]
]
>>> print(optional_members)
shape: (3,)
Series: 'optional_members' [i64]
[
    1
    2
    3
]
>>> optional_members.is_in(sets)
shape: (3,)
Series: 'optional_members' [bool]
[
    true
    true
    false
]
Nr  )r   r6  r  s      r   is_inSeries.is_in  r  r   c                ,    [         R                  " U SS9$ )z
Get index values where Boolean Series evaluate True.

Returns
-------
Series
    Series of data type :class:`UInt32`.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3])
>>> (s == 2).arg_true()
shape: (1,)
Series: 'a' [u32]
[
        1
]
T)eager)r=  	arg_wherer   s    r   arg_trueSeries.arg_true  s    & {{4t,,r   c                    g)a  
Get mask of all unique values.

Returns
-------
Series
    Series of data type :class:`Boolean`.

Examples
--------
>>> s = pl.Series("a", [1, 2, 2, 3])
>>> s.is_unique()
shape: (4,)
Series: 'a' [bool]
[
        true
        false
        false
        true
]
Nr  r   s    r   	is_uniqueSeries.is_unique   r  r   c                    g)aF  
Return a boolean mask indicating the first occurrence of each distinct value.

Returns
-------
Series
    Series of data type :class:`Boolean`.

Examples
--------
>>> s = pl.Series([1, 1, 2, 3, 2])
>>> s.is_first_distinct()
shape: (5,)
Series: '' [bool]
[
        true
        false
        true
        true
        false
]
Nr  r   s    r   is_first_distinctSeries.is_first_distinct  r  r   c                    g)aD  
Return a boolean mask indicating the last occurrence of each distinct value.

Returns
-------
Series
    Series of data type :class:`Boolean`.

Examples
--------
>>> s = pl.Series([1, 1, 2, 3, 2])
>>> s.is_last_distinct()
shape: (5,)
Series: '' [bool]
[
        false
        true
        false
        true
        true
]
Nr  r   s    r   is_last_distinctSeries.is_last_distinct/  r  r   c                    g)a  
Get mask of all duplicated values.

Returns
-------
Series
    Series of data type :class:`Boolean`.

Examples
--------
>>> s = pl.Series("a", [1, 2, 2, 3])
>>> s.is_duplicated()
shape: (4,)
Series: 'a' [bool]
[
        false
        true
        true
        false
]
Nr  r   s    r   is_duplicatedSeries.is_duplicatedG  r  r   c                    g)a  
Explode a list Series.

This means that every item is expanded to a new row.

Returns
-------
Series
    Series with the data type of the list elements.

See Also
--------
Series.list.explode : Explode a list column.

Examples
--------
>>> s = pl.Series("a", [[1, 2, 3], [4, 5, 6]])
>>> s
shape: (2,)
Series: 'a' [list[i64]]
[
        [1, 2, 3]
        [4, 5, 6]
]
>>> s.explode()
shape: (6,)
Series: 'a' [i64]
[
        1
        2
        3
        4
        5
        6
]
Nr  r   s    r   explodeSeries.explode^  r  r   check_dtypesz0.20.31r  check_names
null_equalc               d    [        X5        U R                  R                  UR                  UUUS9$ )a  
Check whether the Series is equal to another Series.

.. versionchanged:: 0.20.31
    The `strict` parameter was renamed `check_dtypes`.

Parameters
----------
other
    Series to compare with.
check_dtypes
    Require data types to match.
check_names
    Require names to match.
null_equal
    Consider null values as equal.

See Also
--------
polars.testing.assert_series_equal

Examples
--------
>>> s1 = pl.Series("a", [1, 2, 3])
>>> s2 = pl.Series("b", [4, 5, 6])
>>> s1.equals(s1)
True
>>> s1.equals(s2)
False
r  )r+   r   equals)r   r6  r  r  r  s        r   r  Series.equals  s7    N 	$&ww~~HH%#!	  
 	
r   )r   wrap_numericalc               n    [        U5      nU R                  U R                  R                  XU5      5      $ )a  
Cast between data types.

Parameters
----------
dtype
    DataType to cast to.
strict
    If True invalid casts generate exceptions instead of `null`\s.
wrap_numerical
    If True numeric casts wrap overflowing values instead of
    marking the cast as invalid.

Examples
--------
>>> s = pl.Series("a", [True, False, True])
>>> s
shape: (3,)
Series: 'a' [bool]
[
    true
    false
    true
]

>>> s.cast(pl.UInt32)
shape: (3,)
Series: 'a' [u32]
[
    1
    0
    1
]
)rH   r   r   r   )r   r   r   r  s       r   r   Series.cast  s/    T !'""477<<~#NOOr   c                    g)a  
Cast to physical representation of the logical dtype.

- :func:`polars.datatypes.Date` -> :func:`polars.datatypes.Int32`
- :func:`polars.datatypes.Datetime` -> :func:`polars.datatypes.Int64`
- :func:`polars.datatypes.Time` -> :func:`polars.datatypes.Int64`
- :func:`polars.datatypes.Duration` -> :func:`polars.datatypes.Int64`
- :func:`polars.datatypes.Categorical` -> :func:`polars.datatypes.UInt32`
- `List(inner)` -> `List(physical of inner)`
- `Array(inner)` -> `Array(physical of inner)`
- `Struct(fields)` -> `Struct(physical of fields)`
- Other data types will be left unchanged.

Warnings
--------
The physical representations are an implementation detail
and not guaranteed to be stable.

Examples
--------
Replicating the pandas
`pd.Series.factorize
<https://pandas.pydata.org/docs/reference/api/pandas.Series.factorize.html>`_
method.

>>> s = pl.Series("values", ["a", None, "x", "a"])
>>> s.cast(pl.Categorical).to_physical()
shape: (4,)
Series: 'values' [u32]
[
    0
    null
    1
    0
]
Nr  r   s    r   r  Series.to_physical  r  r   c                6    U R                   R                  5       $ )z
Convert this Series to a Python list.

This operation copies data.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3])
>>> s.to_list()
[1, 2, 3]
>>> type(s.to_list())
<class 'list'>
)r   rR  r   s    r   rR  Series.to_list  r  r   rv  c               v    U R                   R                  U5      nU(       a  U $ Uc   eU R                  U5      $ )a  
Create a single chunk of memory for this Series.

Parameters
----------
in_place
    In place or not.

Examples
--------
>>> s1 = pl.Series("a", [1, 2, 3])
>>> s1.n_chunks()
1
>>> s2 = pl.Series("a", [4, 5, 6])
>>> s = pl.concat([s1, s2], rechunk=False)
>>> s.n_chunks()
2
>>> s.rechunk(in_place=True)
shape: (6,)
Series: 'a' [i64]
[
        1
        2
        3
        4
        5
        6
]
>>> s.n_chunks()
1
)r   r  r   )r   rw  opt_ss      r   r  Series.rechunk  s<    @ )K$$$&&u--r   c                    g)z
Return Series in reverse order.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3], dtype=pl.Int8)
>>> s.reverse()
shape: (3,)
Series: 'a' [i8]
[
    3
    2
    1
]
Nr  r   s    r   rU  Series.reverse=  r  r   c                
   US:X  a
  X:  X:  -  nO/US:X  a
  X:  X:*  -  nOUS:X  a
  X:  X:*  -  nOUS:X  a	  X:  X:  -  n[        W[        R                  5      (       a$  [        R                  " U5      R                  5       nU$ )a  
Get a boolean mask of the values that are between the given lower/upper bounds.

Parameters
----------
lower_bound
    Lower bound value. Accepts expression input. Non-expression inputs
    (including strings) are parsed as literals.
upper_bound
    Upper bound value. Accepts expression input. Non-expression inputs
    (including strings) are parsed as literals.
closed : {'both', 'left', 'right', 'none'}
    Define which sides of the interval are closed (inclusive).

Notes
-----
If the value of the `lower_bound` is greater than that of the `upper_bound`
then the result will be False, as no value can satisfy the condition.

Examples
--------
>>> s = pl.Series("num", [1, 2, 3, 4, 5])
>>> s.is_between(2, 4)
shape: (5,)
Series: 'num' [bool]
[
    false
    true
    true
    true
    false
]

Use the `closed` argument to include or exclude the values at the bounds:

>>> s.is_between(2, 4, closed="left")
shape: (5,)
Series: 'num' [bool]
[
    false
    true
    true
    false
    false
]

You can also use strings as well as numeric/temporal values:

>>> s = pl.Series("s", ["a", "b", "c", "d", "e"])
>>> s.is_between("b", "d", closed="both")
shape: (5,)
Series: 's' [bool]
[
    false
    true
    true
    true
    false
]
nonebothrightleft)r   r   rs   r=  r  r  )r   lower_boundupper_boundclosedr  s        r   
is_betweenSeries.is_betweenN  s    D V%$*<=Cv&4+>?Cw%$*=>Cv&4+=>Cc277##((3-))+C
r   g        g&.>abs_tolrel_tol
nans_equalc          	         [         R                  " [         R                  " U 5      R                  XX4S95      R	                  5       $ )a  
Get a boolean mask of the values being close to the other values.

Two values `a` and `b` are considered close if the following condition holds:

.. math::
    |a-b| \le max \{ \text{rel_tol} \cdot max \{ |a|, |b| \}, \text{abs_tol} \}

Parameters
----------
abs_tol
    Absolute tolerance. This is the maximum allowed absolute difference between
    two values. Must be non-negative.
rel_tol
    Relative tolerance. This is the maximum allowed difference between two
    values, relative to the larger absolute value. Must be non-negative.
nans_equal
    Whether NaN values should be considered equal.

Returns
-------
Series
    Series of data type :class:`Boolean`.

Notes
-----
    The implementation of this method is symmetric and mirrors the behavior of
    :meth:`math.isclose`. Specifically note that this behavior is different to
    :meth:`numpy.isclose`.

Examples
--------
>>> s = pl.Series("s", [1.0, 1.2, 1.4, 1.45, 1.6])
>>> s.is_close(1.4, abs_tol=0.1)
shape: (5,)
Series: 's' [bool]
[
    false
    false
    true
    true
    false
]
r  )r=  r  r>  is_closer  )r   r6  r  r  r  s        r   r  Series.is_close  s?    h xxEE$K   ! 
 )+		r   )rn  ro  use_pyarrowzero_copy_onlyc                  Ub  [        SSS9  U(       + nUb  [        SSS9  OSnU(       a  [        (       a  U R                  [        [        [
        [        [        4;  a`  U(       d6  U R                  5       S:  a"  U R                  5       (       d  Sn[        U5      eU R                  5       R                  U(       + US	9$ U R                  R                  XS
9$ )a	  
Convert this Series to a NumPy ndarray.

This operation copies data only when necessary. The conversion is zero copy when
all of the following hold:

- The data type is an integer, float, `Datetime`, `Duration`, or `Array`.
- The Series contains no null values.
- The Series consists of a single chunk.
- The `writable` parameter is set to `False` (default).

Parameters
----------
writable
    Ensure the resulting array is writable. This will force a copy of the data
    if the array was created without copy as the underlying Arrow data is
    immutable.
allow_copy
    Allow memory to be copied to perform the conversion. If set to `False`,
    causes conversions that are not zero-copy to fail.

use_pyarrow
    First convert to PyArrow, then call `pyarrow.Array.to_numpy
    <https://arrow.apache.org/docs/python/generated/pyarrow.Array.html#pyarrow.Array.to_numpy>`_
    to convert to NumPy. If set to `False`, Polars' own conversion logic is
    used.

    .. deprecated:: 0.20.28
        Polars now uses its native engine by default for conversion to NumPy.
        To use PyArrow's engine, call `.to_arrow().to_numpy()` instead.

zero_copy_only
    Raise an exception if the conversion to a NumPy would require copying
    the underlying data. Data copy occurs, for example, when the Series contains
    nulls or non-numeric types.

    .. deprecated:: 0.20.10
        Use the `allow_copy` parameter instead, which is the inverse of this
        one.

Examples
--------
Numeric data without nulls can be converted without copying data.
The resulting array will not be writable.

>>> s = pl.Series([1, 2, 3], dtype=pl.Int8)
>>> arr = s.to_numpy()
>>> arr
array([1, 2, 3], dtype=int8)
>>> arr.flags.writeable
False

Set `writable=True` to force data copy to make the array writable.

>>> s.to_numpy(writable=True).flags.writeable
True

Integer Series containing nulls will be cast to a float type with `nan`
representing a null value. This requires data to be copied.

>>> s = pl.Series([1, 2, None], dtype=pl.UInt16)
>>> s.to_numpy()
array([ 1.,  2., nan], dtype=float32)

Set `allow_copy=False` to raise an error if data would be copied.

>>> s.to_numpy(allow_copy=False)  # doctest: +SKIP
Traceback (most recent call last):
...
RuntimeError: copy not allowed: cannot convert to a NumPy array without copying data

Series of data type `Array` and `Struct` will result in an array with more than
one dimension.

>>> s = pl.Series([[1, 2, 3], [4, 5, 6]], dtype=pl.Array(pl.Int64, 3))
>>> s.to_numpy()
array([[1, 2, 3],
       [4, 5, 6]])
zthe `zero_copy_only` parameter for `Series.to_numpy` is deprecated. Use the `allow_copy` parameter instead, which is the inverse of `zero_copy_only`.z0.20.10rF  zthe `use_pyarrow` parameter for `Series.to_numpy` is deprecated. Polars now uses its native engine for conversion to NumPy by default. To use PyArrow's engine, call `.to_arrow().to_numpy()` instead.z0.20.28Fr%  zcannot return a zero-copy array)r  rn  rm  )r"   rL   r   r4   r5   r6   r1   r>   r  r  rl  to_arrowrp  r   )r   rn  ro  r  r  r   s         r   rp  Series.to_numpy  s    n %%e!
 ,+J"%S "	  K ""

48UF"KK$--/A"5dmmoo7 o%==?++#-~ ,   wwIIr   c                   [        SSS9n[        U[        5      (       a  UR                  U5      S   nUR                  R
                  (       dV  [        [        [        R                  R                  SS5      5      5      (       d  U R                  [        [        [        1;  a  U nO=[        [        [        [         [        ["        0nU R%                  X@R                     5      nUc
  ['        5       OUR)                  U5         UR*                  R-                  UR/                  SS	9S
S9sSSS5        $ ! , (       d  f       g= f)a  
Convert this Series to a Jax Array.

.. versionadded:: 0.20.27

.. warning::
    This functionality is currently considered **unstable**. It may be
    changed at any point without it being considered a breaking change.

Parameters
----------
device
    Specify the jax `Device` on which the array will be created; can provide
    a string (such as "cpu", "gpu", or "tpu") in which case the device is
    retrieved as `jax.devices(string)[0]`. For more specific control you
    can supply the instantiated `Device` directly. If None, arrays are
    created on the default device.

Examples
--------
>>> s = pl.Series("x", [10.5, 0.0, -10.0, 5.5])
>>> s.to_jax()
Array([ 10.5,   0. , -10. ,   5.5], dtype=float32)
jaxzPlease see `https://jax.readthedocs.io/en/latest/installation.html` for specific installation recommendations for the Jax package)install_messager   JAX_ENABLE_X640NFrn  K)aorder)rR   r   r   devicesconfigjax_enable_x64re  r  osenvirongetr   r9   r;   rC   r8   r:   rB   r   r   default_devicerT   asarrayrp  )r   devicejxsrssingle_precisions        r   to_jaxSeries.to_jaxP  s    4 L

 fc""ZZ'*FII$$C

'7=>??zz'5&!99C '%O)),ZZ89C$n[]"2C2CF2KK88##,,,. $  LKKs   'D44
Ec                z   [        S5      nU R                  [        [        4;   a  U R	                  [
        5      nO,U R                  [        :X  a  U R	                  [        5      nOU nUR                  SS9n UR                  " U5      nU$ ! [         a$    U R                  [        :X  a  Sn[        U5      See f = f)av  
Convert this Series to a PyTorch Tensor.

.. versionadded:: 0.20.23

.. warning::
    This functionality is currently considered **unstable**. It may be
    changed at any point without it being considered a breaking change.

Notes
-----
PyTorch tensors do not support UInt16, UInt32, or UInt64; these dtypes
will be automatically cast to Int32, Int64, and Int64, respectively.

Examples
--------
>>> s = pl.Series("x", [1, 0, 1, 2, 0], dtype=pl.UInt8)
>>> s.to_torch()
tensor([1, 0, 1, 2, 0], dtype=torch.uint8)
>>> s = pl.Series("x", [5.5, -10.0, 2.5], dtype=pl.Float32)
>>> s.to_torch()
tensor([  5.5000, -10.0000,   2.5000])
rS   Tr  z=cannot convert List dtype to Tensor (use Array dtype instead)N)rR   r   rB   rC   r   r;   rA   r:   rp  
from_numpyr   r<   )r   rS   r*  numpy_arraytensorr   s         r   to_torchSeries.to_torch  s    2  ( ::&&))))E"CZZ6!))E"CC llDl1	%%k2F   	zzT!Un$.		s   8B .B:futurecompat_levelz1.1)r5  c                   Uc  SnO<[        U[        5      (       a  UR                  nOS[        U5      < 3n[	        U5      eU R
                  R                  U5      $ )a  
Return the underlying Arrow array.

If the Series contains only a single chunk this operation is zero copy.

.. versionchanged:: 1.24
    The `future` parameter was renamed `compat_level`.

Parameters
----------
compat_level
    Use a specific compatibility level
    when exporting Polars' internal data structures.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3])
>>> s = s.to_arrow()
>>> s
<pyarrow.lib.Int64Array object at ...>
[
  1,
  2,
  3
]
Fz!`compat_level` has invalid type: )r   rZ   r  r*   r   r   r  )r   r5  compat_level_pyr   s       r   r  Series.to_arrow  sY    : #Ok22*33O56I,6W5Z[CC. ww00r   )use_pyarrow_extension_arrayc                  U R                   [        :X  a2  [        R                  " U R	                  5       [
        U R                  S9$ U(       a  [        [        R                  5      S:  a  S[        R                   3n[        U5      e[        (       a  [        [        R                  5      S:  a.  [        [        (       a  S[        R                  < 35      eS5      eU R                  5       n[        R                  R                  UR                  5      (       aL  UR!                  [        R"                  " [        R$                  " 5       [        R&                  " 5       5      5      nU(       a  UR(                  " SSSS S	.UD6nO&UR+                  S
S5      nUR(                  " SS
U0UD6nU R                  Ul        U$ )a  
Convert this Series to a pandas Series.

This operation copies data if `use_pyarrow_extension_array` is not enabled.

Parameters
----------
use_pyarrow_extension_array
    Use a PyArrow-backed extension array instead of a NumPy array for the pandas
    Series. This allows zero copy operations and preservation of null values.
    Subsequent operations on the resulting pandas Series may trigger conversion
    to NumPy if those operations are not supported by PyArrow compute functions.
**kwargs
    Additional keyword arguments to be passed to
    :meth:`pyarrow.Array.to_pandas`.

Returns
-------
:class:`pandas.Series`

Notes
-----
This operation requires that both :mod:`pandas` and :mod:`pyarrow` are
installed.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3])
>>> s.to_pandas()
0    1
1    2
2    3
Name: a, dtype: int64

Null values are converted to `NaN`.

>>> s = pl.Series("b", [1, 2, None])
>>> s.to_pandas()
0    1.0
1    2.0
2    NaN
Name: b, dtype: float64

Pass `use_pyarrow_extension_array=True` to get a pandas Series backed by a
PyArrow extension array. This will preserve null values.

>>> s.to_pandas(use_pyarrow_extension_array=True)
0       1
1       2
2    <NA>
Name: b, dtype: int64[pyarrow]
)r   r   )r%     z\pandas>=1.5.0 is required for `to_pandas("use_pyarrow_extension_array=True")`, found Pandas )   r   z^pyarrow>=8.0.0 is required for `to_pandas("use_pyarrow_extension_array=True")`, found pyarrow r   Tc                .    [         R                  " U 5      $ r   )r   
ArrowDtype)pa_dtypes    r   r  "Series.to_pandas.<locals>.<lambda>)  s    bmmH.Er   )self_destructsplit_blockstypes_mapperdate_as_objectFr  )r   r>   r   r   rp  objectr   r)   __version__rX   rL   r   r  r  is_dictionaryr   r   
dictionaryint64large_string	to_pandasr  )r   r9  r~  r   pa_arr	pd_seriesrD  s          r   rK  Series.to_pandas  sq   n ::99T]]_FKK&R^^,v5tuw  vD  vD  uE  F055%%r~~)F)O0 *)'')~~&8:  	  88!!&++..[[rxxz2??;L!MNF&(( "!E 	I $ZZ(8%@N((QQ&QI	r   c                    U R                  U5      R                  5       n[        U R                  5      nSU R                  < SU SU S3$ )a  
Convert Series to instantiable string representation.

Parameters
----------
n
    Only use first n elements.

See Also
--------
polars.Series.to_init_repr
polars.from_repr

Examples
--------
>>> s = pl.Series("a", [1, 2, None, 4], dtype=pl.Int16)
>>> print(s.to_init_repr())
pl.Series('a', [1, 2, None, 4], dtype=pl.Int16)
>>> s_from_str_repr = eval(s.to_init_repr())
>>> s_from_str_repr
shape: (4,)
Series: 'a' [i16]
[
    1
    2
    null
    4
]
z
pl.Series(z, z, dtype=r  )rr  rR  rJ   r   r   )r   rt  r   dtype_init_reprs       r   to_init_reprSeries.to_init_repr3  sH    < 1%%',TZZ8DII=6((?:K1MMr   c                D    U R                  5       U R                  5       -
  $ )z
Return the number of non-null elements in the column.

See Also
--------
len

Examples
--------
>>> s = pl.Series("a", [1, 2, None])
>>> s.count()
2
)r  r  r   s    r   r9  Series.countU  s     xxzDOO---r   c                6    U R                   R                  5       $ )z
Return the number of elements in the Series.

Null values count towards the total.

See Also
--------
count

Examples
--------
>>> s = pl.Series("a", [1, 2, None])
>>> s.len()
3
r  r   s    r   r  
Series.lene  s      ww{{}r   c                    [        SU R                  U R                  5      nUc  SU R                   S3n[        U5      eU R	                  U" UR                  U5      5      $ )u-  
Set masked values.

Parameters
----------
filter
    Boolean mask.
value
    Value with which to replace the masked values.

Notes
-----
Use of this function is frequently an anti-pattern, as it can
block optimisation (predicate pushdown, etc). Consider using
`pl.when(predicate).then(value).otherwise(self)` instead.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3])
>>> s.set(s == 2, 10)
shape: (3,)
Series: 'a' [i64]
[
        1
        10
        3
]

It is better to implement this as follows:

>>> s.to_frame().select(
...     pl.when(pl.col("a") == 2).then(10).otherwise(pl.col("a"))
... )
shape: (3, 1)
┌─────────┐
│ literal │
│ ---     │
│ i64     │
╞═════════╡
│ 1       │
│ 10      │
│ 3       │
└─────────┘
zset_with_mask_<>rd  z can not be set)rk   r   r   rn  r   )r   r  ri  rp  r   s        r   rb  
Series.setw  sZ    Z +TZZA9#DJJ<?C%c**""1VYY#677r   c                p   [        U[        5      (       d  UnU/n[        US9nUR                  5       (       a  U $ [        U[        5      (       d6  [        U[        5      (       a  [        U[        5      (       a  U/n[        US9nU R
                  R                  UR
                  UR
                  5        U $ )uU  
Set values at the index locations.

Parameters
----------
indices
    Integers representing the index locations.
values
    Replacement values.

Notes
-----
Use of this function is frequently an anti-pattern, as it can
block optimization (predicate pushdown, etc). Consider using
`pl.when(predicate).then(value).otherwise(self)` instead.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3])
>>> s.scatter(1, 10)
shape: (3,)
Series: 'a' [i64]
[
        1
        10
        3
]

It is better to implement this as follows:

>>> s.to_frame().with_row_index().select(
...     pl.when(pl.col("index") == 1).then(10).otherwise(pl.col("a"))
... )
shape: (3, 1)
┌─────────┐
│ literal │
│ ---     │
│ i64     │
╞═════════╡
│ 1       │
│ 10      │
│ 3       │
└─────────┘
)r   )r   r   r   r  r   r   r   )r   r  r   r  s       r   r   Series.scatter  s    b '8,, EgG(K&&))fh//:fc3J3J 6*F

FII.r   c                    [         R                  " [         R                  " U 5      R                  U5      5      R	                  5       $ )a  
Get the index of the first occurrence of a value, or ``None`` if it's not found.

Parameters
----------
element
    Value to find.

Examples
--------
>>> s = pl.Series("a", [1, None, 17])
>>> s.index_of(17)
2
>>> s.index_of(None)  # search for a null
1
>>> s.index_of(55) is None
True
)r=  r  r>  index_ofrK  )r   r  s     r   r\  Series.index_of  s/    & xxd,,W56;;==r   c                D   US:  a  SU 3n[        U5      eUS:X  a)  U R                  U R                  R                  5       5      $ [	        U 5      S:  a%  U R                  U R                  / U R                  S9OU R                  5       nUS:  a  UR                  SUS9$ U$ )a  
Create an empty copy of the current Series, with zero to 'n' elements.

The copy has an identical name/dtype, but no data.

Parameters
----------
n
    Number of (empty) elements to return in the cleared frame.

See Also
--------
clone : Cheap deepcopy/clone.

Examples
--------
>>> s = pl.Series("a", [None, True, False])
>>> s.clear()
shape: (0,)
Series: 'a' [bool]
[
]

>>> s.clear(n=2)
shape: (2,)
Series: 'a' [bool]
[
    null
    null
]
r   z.`n` should be greater than or equal to 0, got )r   r   r   N)rt  )
rl  r   r   clearr  r(  r   r   rf  extend_constant)r   rt  r   r   s       r   r_  Series.clear  s    @ q5B1#FCS/!6&&tww}}77 4y1} NN		"DJJNG 	

 011uq   +;!;r   c                T    U R                  U R                  R                  5       5      $ )aD  
Create a copy of this Series.

This is a cheap operation that does not copy data.

See Also
--------
clear : Create an empty copy of the current Series, with identical
    schema but no data.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3])
>>> s.clone()
shape: (3,)
Series: 'a' [i64]
[
        1
        2
        3
]
)r   r   rf  r   s    r   rf  Series.clone,  s    . ""477==?33r   c                    g)a  
Fill floating point NaN value with a fill value.

Parameters
----------
value
    Value used to fill NaN values.

See Also
--------
fill_null

Notes
-----
A NaN value is not the same as a null value.
To fill null values, use :func:`fill_null`.

Examples
--------
>>> s = pl.Series("a", [1.0, 2.0, 3.0, float("nan")])
>>> s.fill_nan(0)
shape: (4,)
Series: 'a' [f64]
[
        1.0
        2.0
        3.0
        0.0
]
Nr  )r   ri  s     r   fill_nanSeries.fill_nanE  r  r   c                    g)ad  
Fill null values using the specified value or strategy.

Parameters
----------
value
    Value used to fill null values.
strategy : {None, 'forward', 'backward', 'min', 'max', 'mean', 'zero', 'one'}
    Strategy used to fill null values.
limit
    Number of consecutive null values to fill when using the 'forward' or
    'backward' strategy.

See Also
--------
backward_fill
fill_nan
forward_fill

Notes
-----
A null value is not the same as a NaN value.
To fill NaN values, use :func:`fill_nan`.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3, None])
>>> s.fill_null(strategy="forward")
shape: (4,)
Series: 'a' [i64]
[
    1
    2
    3
    3
]
>>> s.fill_null(strategy="min")
shape: (4,)
Series: 'a' [i64]
[
    1
    2
    3
    1
]
>>> s = pl.Series("b", ["x", None, "z"])
>>> s.fill_null(pl.lit(""))
shape: (3,)
Series: 'b' [str]
[
    "x"
    ""
    "z"
]
Nr  )r   ri  strategyr{  s       r   	fill_nullSeries.fill_nulle  r  r   c                "    U R                  SUS9$ )z
Fill missing values with the next non-null value.

This is an alias of `.fill_null(strategy="backward")`.

Parameters
----------
limit
    The number of consecutive null values to backward fill.

See Also
--------
fill_null
forward_fill
shift
backwardrh  r{  ri  r   r{  s     r   backward_fillSeries.backward_fill  s    " ~~z~??r   c                "    U R                  SUS9$ )z
Fill missing values with the last non-null value.

This is an alias of `.fill_null(strategy="forward")`.

Parameters
----------
limit
    The number of consecutive null values to forward fill.

See Also
--------
backward_fill
fill_null
shift
forwardrm  rn  ro  s     r   forward_fillSeries.forward_fill  s    " ~~y~>>r   c                    g)z
Rounds down to the nearest integer value.

Only works on floating point Series.

Examples
--------
>>> s = pl.Series("a", [1.12345, 2.56789, 3.901234])
>>> s.floor()
shape: (3,)
Series: 'a' [f64]
[
        1.0
        2.0
        3.0
]
Nr  r   s    r   floorSeries.floor  r  r   c                    g)z
Rounds up to the nearest integer value.

Only works on floating point Series.

Examples
--------
>>> s = pl.Series("a", [1.12345, 2.56789, 3.901234])
>>> s.ceil()
shape: (3,)
Series: 'a' [f64]
[
        2.0
        3.0
        4.0
]
Nr  r   s    r   ceilSeries.ceil  r  r   c                    g)az  
Round underlying floating point data by `decimals` digits.

The default rounding mode is "half to even" (also known as "bankers' rounding").

Parameters
----------
decimals
    Number of decimals to round by.
mode : {'half_to_even', 'half_away_from_zero'}
    Rounding mode.

Examples
--------
>>> s = pl.Series("a", [1.12345, 2.56789, 3.901234])
>>> s.round(2)
shape: (3,)
Series: 'a' [f64]
[
        1.12
        2.57
        3.9
]

>>> s = pl.Series([-3.5, -2.5, -1.5, -0.5, 0.5, 1.5, 2.5, 3.5])
>>> s.round(mode="half_to_even")
shape: (8,)
Series: '' [f64]
[
    -4.0
    -2.0
    -2.0
    -0.0
    0.0
    2.0
    2.0
    4.0
]
Nr  )r   decimalsmodes      r   roundSeries.round  r  r   c                    g)a  
Round to a number of significant figures.

Parameters
----------
digits
    Number of significant figures to round to.

Examples
--------
>>> s = pl.Series([0.01234, 3.333, 3450.0])
>>> s.round_sig_figs(2)
shape: (3,)
Series: '' [f64]
[
        0.012
        3.3
        3500.0
]
Nr  )r   digitss     r   round_sig_figsSeries.round_sig_figs  r  r   c                   [        U[        5      (       d  [        U5      n[        U 5      [        U5      :w  a*  [        U 5      [        U5      p2SU< SU< 3n[        U5      eU R                  R                  UR                  5      $ )z
Compute the dot/inner product between two Series.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3])
>>> s2 = pl.Series("b", [4.0, 5.0, 6.0])
>>> s.dot(s2)
32.0

Parameters
----------
other
    Series (or array) to compute dot product with.
z!Series length mismatch: expected z, found )r   r   r  rY   r   r.  )r   r6  rt  mr   s        r   r.  
Series.dot.  sl      %((5MEt9E
"t9c%jq5aU(1%HCS/!ww{{588$$r   c                    g)z
Compute the most occurring value(s).

Can return multiple Values.

Examples
--------
>>> s = pl.Series("a", [1, 2, 2, 3])
>>> s.mode()
shape: (1,)
Series: 'a' [i64]
[
        2
]
Nr  r   s    r   r~  Series.modeF  r  r   c                    g)a  
Compute the element-wise sign function on numeric types.

The returned value is computed as follows:

* -1 if x < 0.
*  1 if x > 0.
*  x otherwise (typically 0, but could be NaN if the input is).

Null values are preserved as-is, and the dtype of the input is preserved.

Examples
--------
>>> s = pl.Series("a", [-9.0, -0.0, 0.0, 4.0, float("nan"), None])
>>> s.sign()
shape: (6,)
Series: 'a' [f64]
[
        -1.0
        -0.0
        0.0
        1.0
        NaN
        null
]
Nr  r   s    r   signSeries.signW  r  r   c                    g)z
Compute the element-wise value for the sine.

Examples
--------
>>> import math
>>> s = pl.Series("a", [0.0, math.pi / 2.0, math.pi])
>>> s.sin()
shape: (3,)
Series: 'a' [f64]
[
    0.0
    1.0
    1.2246e-16
]
Nr  r   s    r   sin
Series.sins  r  r   c                    g)z
Compute the element-wise value for the cosine.

Examples
--------
>>> import math
>>> s = pl.Series("a", [0.0, math.pi / 2.0, math.pi])
>>> s.cos()
shape: (3,)
Series: 'a' [f64]
[
    1.0
    6.1232e-17
    -1.0
]
Nr  r   s    r   cos
Series.cos  r  r   c                    g)z
Compute the element-wise value for the tangent.

Examples
--------
>>> import math
>>> s = pl.Series("a", [0.0, math.pi / 2.0, math.pi])
>>> s.tan()
shape: (3,)
Series: 'a' [f64]
[
    0.0
    1.6331e16
    -1.2246e-16
]
Nr  r   s    r   tan
Series.tan  r  r   c                    g)z
Compute the element-wise value for the cotangent.

Examples
--------
>>> import math
>>> s = pl.Series("a", [0.0, math.pi / 2.0, math.pi])
>>> s.cot()
shape: (3,)
Series: 'a' [f64]
[
    inf
    6.1232e-17
    -8.1656e15
]
Nr  r   s    r   cot
Series.cot  r  r   c                    g)z
Compute the element-wise value for the inverse sine.

Examples
--------
>>> s = pl.Series("a", [1.0, 0.0, -1.0])
>>> s.arcsin()
shape: (3,)
Series: 'a' [f64]
[
    1.570796
    0.0
    -1.570796
]
Nr  r   s    r   arcsinSeries.arcsin  r  r   c                    g)z
Compute the element-wise value for the inverse cosine.

Examples
--------
>>> s = pl.Series("a", [1.0, 0.0, -1.0])
>>> s.arccos()
shape: (3,)
Series: 'a' [f64]
[
    0.0
    1.570796
    3.141593
]
Nr  r   s    r   arccosSeries.arccos  r  r   c                    g)z
Compute the element-wise value for the inverse tangent.

Examples
--------
>>> s = pl.Series("a", [1.0, 0.0, -1.0])
>>> s.arctan()
shape: (3,)
Series: 'a' [f64]
[
    0.785398
    0.0
    -0.785398
]
Nr  r   s    r   arctanSeries.arctan  r  r   c                    g)z
Compute the element-wise value for the inverse hyperbolic sine.

Examples
--------
>>> s = pl.Series("a", [1.0, 0.0, -1.0])
>>> s.arcsinh()
shape: (3,)
Series: 'a' [f64]
[
    0.881374
    0.0
    -0.881374
]
Nr  r   s    r   arcsinhSeries.arcsinh  r  r   c                    g)z
Compute the element-wise value for the inverse hyperbolic cosine.

Examples
--------
>>> s = pl.Series("a", [5.0, 1.0, 0.0, -1.0])
>>> s.arccosh()
shape: (4,)
Series: 'a' [f64]
[
    2.292432
    0.0
    NaN
    NaN
]
Nr  r   s    r   arccoshSeries.arccosh  r  r   c                    g)a  
Compute the element-wise value for the inverse hyperbolic tangent.

Examples
--------
>>> s = pl.Series("a", [2.0, 1.0, 0.5, 0.0, -0.5, -1.0, -1.1])
>>> s.arctanh()
shape: (7,)
Series: 'a' [f64]
[
    NaN
    inf
    0.549306
    0.0
    -0.549306
    -inf
    NaN
]
Nr  r   s    r   arctanhSeries.arctanh  r  r   c                    g)z
Compute the element-wise value for the hyperbolic sine.

Examples
--------
>>> s = pl.Series("a", [1.0, 0.0, -1.0])
>>> s.sinh()
shape: (3,)
Series: 'a' [f64]
[
    1.175201
    0.0
    -1.175201
]
Nr  r   s    r   sinhSeries.sinh&  r  r   c                    g)z
Compute the element-wise value for the hyperbolic cosine.

Examples
--------
>>> s = pl.Series("a", [1.0, 0.0, -1.0])
>>> s.cosh()
shape: (3,)
Series: 'a' [f64]
[
    1.543081
    1.0
    1.543081
]
Nr  r   s    r   coshSeries.cosh7  r  r   c                    g)z
Compute the element-wise value for the hyperbolic tangent.

Examples
--------
>>> s = pl.Series("a", [1.0, 0.0, -1.0])
>>> s.tanh()
shape: (3,)
Series: 'a' [f64]
[
    0.761594
    0.0
    -0.761594
]
Nr  r   s    r   tanhSeries.tanhH  r  r   )
skip_nullsc                   SSK Jn  Uc  SnO[        U5      nU" XR                  /SS9  U R	                  U R
                  R                  XUS95      $ )u	  
Map a custom/user-defined function (UDF) over elements in this Series.

.. warning::
    This method is much slower than the native expressions API.
    Only use it if you cannot implement your logic otherwise.

    Suppose that the function is: `x ↦ sqrt(x)`:

    - For mapping elements of a series, consider: `s.sqrt()`.
    - For mapping inner elements of lists, consider:
      `s.list.eval(pl.element().sqrt())`.
    - For mapping elements of struct fields, consider:
      `s.struct.field("field_name").sqrt()`.

If the function returns a different datatype, the return_dtype arg should
be set, otherwise the method will fail.

Implementing logic using a Python function is almost always *significantly*
slower and more memory intensive than implementing the same logic using
the native expression API because:

- The native expression engine runs in Rust; UDFs run in Python.
- Use of Python UDFs forces the DataFrame to be materialized in memory.
- Polars-native expressions can be parallelised (UDFs typically cannot).
- Polars-native expressions can be logically optimised (UDFs cannot).

Wherever possible you should strongly prefer the native expression API
to achieve the best performance.

Parameters
----------
function
    Custom function or lambda.
return_dtype
    Output datatype.
    If not set, the dtype will be inferred based on the first non-null value
    that is returned by the function.
skip_nulls
    Nulls will be skipped and not passed to the python function.
    This is faster because python can be skipped and because we call
    more specialized functions.

Warnings
--------
If `return_dtype` is not provided, this may lead to unexpected results.
We allow this, but it is considered a bug in the user's query.

Notes
-----
* If your function is expensive and you don't want it to be called more than
  once for a given input, consider applying an `@lru_cache` decorator to it.
  If your data is suitable you may achieve *significant* speedups.

* A UDF passed to `map_elements` must be pure, meaning that it cannot modify
  or depend on state other than its arguments.


Examples
--------
>>> s = pl.Series("a", [1, 2, 3])
>>> s.map_elements(lambda x: x + 10, return_dtype=pl.Int64)  # doctest: +SKIP
shape: (3,)
Series: 'a' [i64]
[
        11
        12
        13
]

Returns
-------
Series
r   )warn_on_inefficient_mapNr   )r  
map_target)return_dtyper  )polars._utils.udfsr  rH   r   r   r   map_elements)r   functionr  r  r  pl_return_dtypes         r   r  Series.map_elementsY  s\    b 	?"O.|<O99+(S""GG  : ! 
 	
r   )
fill_valuec                   g)a  
Shift values by the given number of indices.

Parameters
----------
n
    Number of indices to shift forward. If a negative value is passed, values
    are shifted in the opposite direction instead.
fill_value
    Fill the resulting null values with this value. Accepts scalar expression
    input. Non-expression inputs are parsed as literals.

Notes
-----
This method is similar to the `LAG` operation in SQL when the value for `n`
is positive. With a negative value for `n`, it is similar to `LEAD`.

Examples
--------
By default, values are shifted forward by one index.

>>> s = pl.Series([1, 2, 3, 4])
>>> s.shift()
shape: (4,)
Series: '' [i64]
[
        null
        1
        2
        3
]

Pass a negative value to shift in the opposite direction instead.

>>> s.shift(-2)
shape: (4,)
Series: '' [i64]
[
        3
        4
        null
        null
]

Specify `fill_value` to fill the resulting null values.

>>> s.shift(-2, fill_value=100)
shape: (4,)
Series: '' [i64]
[
        3
        4
        100
        100
]
Nr  )r   rt  r  s      r   shiftSeries.shift  r  r   c                    [        X5        U R                  U R                  R                  UR                  UR                  5      5      $ )av  
Take values from self or other based on the given mask.

Where mask evaluates true, take values from self. Where mask evaluates false,
take values from other.

Parameters
----------
mask
    Boolean Series.
other
    Series of same type.

Returns
-------
Series

Examples
--------
>>> s1 = pl.Series([1, 2, 3, 4, 5])
>>> s2 = pl.Series([5, 4, 3, 2, 1])
>>> s1.zip_with(s1 < s2, s2)
shape: (5,)
Series: '' [i64]
[
        1
        2
        3
        2
        1
]
>>> mask = pl.Series([True, False, True, False, True])
>>> s1.zip_with(mask, s2)
shape: (5,)
Series: '' [i64]
[
        1
        4
        3
        2
        5
]
)r+   r   r   zip_with)r   maskr6  s      r   r  Series.zip_with  s7    X 	$&""477#3#3DGGUXX#FGGr   r  )rE  r  c                   g)u
  
Compute a rolling min based on another series.

.. warning::
    This functionality is considered **unstable**. It may be changed
    at any point without it being considered a breaking change.

Given a `by` column `<t_0, t_1, ..., t_n>`, then `closed="right"`
(the default) means the windows will be:

    - (t_0 - window_size, t_0]
    - (t_1 - window_size, t_1]
    - ...
    - (t_n - window_size, t_n]

Parameters
----------
by
    Should be ``DateTime``, ``Date``, ``UInt64``, ``UInt32``, ``Int64``,
    or ``Int32`` data type (note that the integral ones require using `'i'`
    in `window size`).
window_size
    The length of the window. Can be a dynamic temporal
    size indicated by a timedelta or the following string language:

    - 1ns   (1 nanosecond)
    - 1us   (1 microsecond)
    - 1ms   (1 millisecond)
    - 1s    (1 second)
    - 1m    (1 minute)
    - 1h    (1 hour)
    - 1d    (1 calendar day)
    - 1w    (1 calendar week)
    - 1mo   (1 calendar month)
    - 1q    (1 calendar quarter)
    - 1y    (1 calendar year)
    - 1i    (1 index count)

    By "calendar day", we mean the corresponding time on the next day
    (which may not be 24 hours, due to daylight savings). Similarly for
    "calendar week", "calendar month", "calendar quarter", and
    "calendar year".
min_samples
    The number of values in the window that should be non-null before computing
    a result.
closed : {'left', 'right', 'both', 'none'}
    Define which sides of the temporal interval are closed (inclusive),
    defaults to `'right'`.

Notes
-----
If you want to compute multiple aggregation statistics over the same dynamic
window, consider using `rolling` - this method can cache the window size
computation.

Examples
--------
Create a series with a row index value

>>> from datetime import timedelta, datetime
>>> start = datetime(2001, 1, 1)
>>> stop = datetime(2001, 1, 2)
>>> s = pl.Series("index", range(25))
>>> s
shape: (25,)
Series: 'index' [i64]
[
    0
    1
    2
    3
    4
    …
    20
    21
    22
    23
    24
]

Create another series to apply the window mask:

>>> d = pl.Series("date", pl.datetime_range(start, stop, "1h", eager=True))
>>> d
shape: (25,)
Series: 'date' [datetime[μs]]
[
    2001-01-01 00:00:00
    2001-01-01 01:00:00
    2001-01-01 02:00:00
    2001-01-01 03:00:00
    2001-01-01 04:00:00
    …
    2001-01-01 20:00:00
    2001-01-01 21:00:00
    2001-01-01 22:00:00
    2001-01-01 23:00:00
    2001-01-02 00:00:00
]

Compute the rolling min with the temporal windows
from the second series closed on the right:

>>> s.rolling_min_by(d, "3h")
shape: (25,)
Series: 'index' [i64]
[
    0
    0
    0
    1
    2
    …
    18
    19
    20
    21
    22
]
Nr  r   r  window_sizerE  r  s        r   rolling_min_bySeries.rolling_min_by!  r  r   )rE  centerc                   g)aS  
Apply a rolling min (moving min) over the values in this array.

A window of length `window_size` will traverse the array. The values that fill
this window will (optionally) be multiplied with the weights given by the
`weight` vector. The resulting values will be aggregated to their min.

The window at a given row will include the row itself and the `window_size - 1`
elements before it.

.. versionchanged:: 1.21.0
    The `min_periods` parameter was renamed `min_samples`.

Parameters
----------
window_size
    The length of the window in number of elements.
weights
    An optional slice with the same length as the window that will be multiplied
    elementwise with the values in the window.
min_samples
    The number of values in the window that should be non-null before computing
    a result. If set to `None` (default), it will be set equal to `window_size`.
center
    Set the labels at the center of the window.

Examples
--------
>>> s = pl.Series("a", [100, 200, 300, 400, 500])
>>> s.rolling_min(window_size=3)
shape: (5,)
Series: 'a' [i64]
[
    null
    null
    100
    200
    300
]
Nr  r   r  weightsrE  r  s        r   rolling_minSeries.rolling_min  r  r   c                   g)u
  
Compute a rolling max based on another series.

.. warning::
    This functionality is considered **unstable**. It may be changed
    at any point without it being considered a breaking change.

Given a `by` column `<t_0, t_1, ..., t_n>`, then `closed="right"`
(the default) means the windows will be:

    - (t_0 - window_size, t_0]
    - (t_1 - window_size, t_1]
    - ...
    - (t_n - window_size, t_n]

Parameters
----------
by
    Should be ``DateTime``, ``Date``, ``UInt64``, ``UInt32``, ``Int64``,
    or ``Int32`` data type (note that the integral ones require using `'i'`
    in `window size`).
window_size
    The length of the window. Can be a dynamic temporal
    size indicated by a timedelta or the following string language:

    - 1ns   (1 nanosecond)
    - 1us   (1 microsecond)
    - 1ms   (1 millisecond)
    - 1s    (1 second)
    - 1m    (1 minute)
    - 1h    (1 hour)
    - 1d    (1 calendar day)
    - 1w    (1 calendar week)
    - 1mo   (1 calendar month)
    - 1q    (1 calendar quarter)
    - 1y    (1 calendar year)
    - 1i    (1 index count)

    By "calendar day", we mean the corresponding time on the next day
    (which may not be 24 hours, due to daylight savings). Similarly for
    "calendar week", "calendar month", "calendar quarter", and
    "calendar year".
min_samples
    The number of values in the window that should be non-null before computing
    a result.
closed : {'left', 'right', 'both', 'none'}
    Define which sides of the temporal interval are closed (inclusive),
    defaults to `'right'`.

Notes
-----
If you want to compute multiple aggregation statistics over the same dynamic
window, consider using `rolling` - this method can cache the window size
computation.

Examples
--------
Create a series with a row index value

>>> from datetime import timedelta, datetime
>>> start = datetime(2001, 1, 1)
>>> stop = datetime(2001, 1, 2)
>>> s = pl.Series("index", range(25))
>>> s
shape: (25,)
Series: 'index' [i64]
[
    0
    1
    2
    3
    4
    …
    20
    21
    22
    23
    24
]

Create another series to apply the window mask:

>>> d = pl.Series("date", pl.datetime_range(start, stop, "1h", eager=True))
>>> d
shape: (25,)
Series: 'date' [datetime[μs]]
[
    2001-01-01 00:00:00
    2001-01-01 01:00:00
    2001-01-01 02:00:00
    2001-01-01 03:00:00
    2001-01-01 04:00:00
    …
    2001-01-01 20:00:00
    2001-01-01 21:00:00
    2001-01-01 22:00:00
    2001-01-01 23:00:00
    2001-01-02 00:00:00
]

Compute the rolling max with the temporal windows
from the second series closed on the right:

>>> s.rolling_max_by(d, "3h")
shape: (25,)
Series: 'index' [i64]
[
    0
    1
    2
    3
    4
    …
    20
    21
    22
    23
    24
]
Nr  r  s        r   rolling_max_bySeries.rolling_max_by  r  r   c                   g)aR  
Apply a rolling max (moving max) over the values in this array.

A window of length `window_size` will traverse the array. The values that fill
this window will (optionally) be multiplied with the weights given by the
`weight` vector. The resulting values will be aggregated to their max.

The window at a given row will include the row itself and the `window_size - 1`
elements before it.

.. versionchanged:: 1.21.0
    The `min_periods` parameter was renamed `min_samples`.

Parameters
----------
window_size
    The length of the window in number of elements.
weights
    An optional slice with the same length as the window that will be multiplied
    elementwise with the values in the window.
min_samples
    The number of values in the window that should be non-null before computing
    a result. If set to `None` (default), it will be set equal to `window_size`.
center
    Set the labels at the center of the window.

Examples
--------
>>> s = pl.Series("a", [100, 200, 300, 400, 500])
>>> s.rolling_max(window_size=2)
shape: (5,)
Series: 'a' [i64]
[
    null
    200
    300
    400
    500
]
Nr  r  s        r   rolling_maxSeries.rolling_maxW  r  r   c                   g)u
  
Compute a rolling mean based on another series.

.. warning::
    This functionality is considered **unstable**. It may be changed
    at any point without it being considered a breaking change.

Given a `by` column `<t_0, t_1, ..., t_n>`, then `closed="right"`
(the default) means the windows will be:

    - (t_0 - window_size, t_0]
    - (t_1 - window_size, t_1]
    - ...
    - (t_n - window_size, t_n]

Parameters
----------
by
    Should be ``DateTime``, ``Date``, ``UInt64``, ``UInt32``, ``Int64``,
    or ``Int32`` data type (note that the integral ones require using `'i'`
    in `window size`).
window_size
    The length of the window. Can be a dynamic temporal
    size indicated by a timedelta or the following string language:

    - 1ns   (1 nanosecond)
    - 1us   (1 microsecond)
    - 1ms   (1 millisecond)
    - 1s    (1 second)
    - 1m    (1 minute)
    - 1h    (1 hour)
    - 1d    (1 calendar day)
    - 1w    (1 calendar week)
    - 1mo   (1 calendar month)
    - 1q    (1 calendar quarter)
    - 1y    (1 calendar year)
    - 1i    (1 index count)

    By "calendar day", we mean the corresponding time on the next day
    (which may not be 24 hours, due to daylight savings). Similarly for
    "calendar week", "calendar month", "calendar quarter", and
    "calendar year".
min_samples
    The number of values in the window that should be non-null before computing
    a result.
closed : {'left', 'right', 'both', 'none'}
    Define which sides of the temporal interval are closed (inclusive),
    defaults to `'right'`.

Notes
-----
If you want to compute multiple aggregation statistics over the same dynamic
window, consider using `rolling` - this method can cache the window size
computation.

Examples
--------
Create a series with a row index value

>>> from datetime import timedelta, datetime
>>> start = datetime(2001, 1, 1)
>>> stop = datetime(2001, 1, 2)
>>> s = pl.Series("index", range(25))
>>> s
shape: (25,)
Series: 'index' [i64]
[
    0
    1
    2
    3
    4
    …
    20
    21
    22
    23
    24
]

Create another series to apply the window mask:

>>> d = pl.Series("date", pl.datetime_range(start, stop, "1h", eager=True))
>>> d
shape: (25,)
Series: 'date' [datetime[μs]]
[
    2001-01-01 00:00:00
    2001-01-01 01:00:00
    2001-01-01 02:00:00
    2001-01-01 03:00:00
    2001-01-01 04:00:00
    …
    2001-01-01 20:00:00
    2001-01-01 21:00:00
    2001-01-01 22:00:00
    2001-01-01 23:00:00
    2001-01-02 00:00:00
]

Compute the rolling mean with the temporal windows
from the second series closed on the right:

>>> s.rolling_mean_by(d, "3h")
shape: (25,)
Series: 'index' [f64]
[
    0.0
    0.5
    1.0
    2.0
    3.0
    …
    19.0
    20.0
    21.0
    22.0
    23.0
]
Nr  r  s        r   rolling_mean_bySeries.rolling_mean_by  r  r   c                   g)a^  
Apply a rolling mean (moving mean) over the values in this array.

A window of length `window_size` will traverse the array. The values that fill
this window will (optionally) be multiplied with the weights given by the
`weight` vector. The resulting values will be aggregated to their mean.

The window at a given row will include the row itself and the `window_size - 1`
elements before it.

.. versionchanged:: 1.21.0
    The `min_periods` parameter was renamed `min_samples`.

Parameters
----------
window_size
    The length of the window in number of elements.
weights
    An optional slice with the same length as the window that will be multiplied
    elementwise with the values in the window.
min_samples
    The number of values in the window that should be non-null before computing
    a result. If set to `None` (default), it will be set equal to `window_size`.
center
    Set the labels at the center of the window.

Examples
--------
>>> s = pl.Series("a", [100, 200, 300, 400, 500])
>>> s.rolling_mean(window_size=2)
shape: (5,)
Series: 'a' [f64]
[
    null
    150.0
    250.0
    350.0
    450.0
]
Nr  r  s        r   rolling_meanSeries.rolling_mean  r  r   c                   g)u
  
Compute a rolling sum based on another series.

.. warning::
    This functionality is considered **unstable**. It may be changed
    at any point without it being considered a breaking change.

Given a `by` column `<t_0, t_1, ..., t_n>`, then `closed="right"`
(the default) means the windows will be:

    - (t_0 - window_size, t_0]
    - (t_1 - window_size, t_1]
    - ...
    - (t_n - window_size, t_n]

Parameters
----------
window_size
    The length of the window. Can be a dynamic temporal
    size indicated by a timedelta or the following string language:

    - 1ns   (1 nanosecond)
    - 1us   (1 microsecond)
    - 1ms   (1 millisecond)
    - 1s    (1 second)
    - 1m    (1 minute)
    - 1h    (1 hour)
    - 1d    (1 calendar day)
    - 1w    (1 calendar week)
    - 1mo   (1 calendar month)
    - 1q    (1 calendar quarter)
    - 1y    (1 calendar year)
    - 1i    (1 index count)

    By "calendar day", we mean the corresponding time on the next day
    (which may not be 24 hours, due to daylight savings). Similarly for
    "calendar week", "calendar month", "calendar quarter", and
    "calendar year".
min_samples
    The number of values in the window that should be non-null before computing
    a result.
by
    Should be ``DateTime``, ``Date``, ``UInt64``, ``UInt32``, ``Int64``,
    or ``Int32`` data type (note that the integral ones require using `'i'`
    in `window size`).
closed : {'left', 'right', 'both', 'none'}
    Define which sides of the temporal interval are closed (inclusive),
    defaults to `'right'`.

Notes
-----
If you want to compute multiple aggregation statistics over the same dynamic
window, consider using `rolling` - this method can cache the window size
computation.

Examples
--------
Create a series with a row index value

>>> from datetime import timedelta, datetime
>>> start = datetime(2001, 1, 1)
>>> stop = datetime(2001, 1, 2)
>>> s = pl.Series("index", range(25))
>>> s
shape: (25,)
Series: 'index' [i64]
[
    0
    1
    2
    3
    4
    …
    20
    21
    22
    23
    24
]

Create another series to apply the window mask:

>>> d = pl.Series("date", pl.datetime_range(start, stop, "1h", eager=True))
>>> d
shape: (25,)
Series: 'date' [datetime[μs]]
[
    2001-01-01 00:00:00
    2001-01-01 01:00:00
    2001-01-01 02:00:00
    2001-01-01 03:00:00
    2001-01-01 04:00:00
    …
    2001-01-01 20:00:00
    2001-01-01 21:00:00
    2001-01-01 22:00:00
    2001-01-01 23:00:00
    2001-01-02 00:00:00
]

Compute the rolling mean with the temporal windows
from the second series closed on the right:

>>> s.rolling_sum_by(d, "3h")
shape: (25,)
Series: 'index' [i64]
[
    0
    1
    3
    6
    9
    …
    57
    60
    63
    66
    69
]
Nr  r  s        r   rolling_sum_bySeries.rolling_sum_by=  r  r   c                   g)aT  
Apply a rolling sum (moving sum) over the values in this array.

A window of length `window_size` will traverse the array. The values that fill
this window will (optionally) be multiplied with the weights given by the
`weight` vector. The resulting values will be aggregated to their sum.

The window at a given row will include the row itself and the `window_size - 1`
elements before it.

.. versionchanged:: 1.21.0
    The `min_periods` parameter was renamed `min_samples`.

Parameters
----------
window_size
    The length of the window in number of elements.
weights
    An optional slice with the same length as the window that will be multiplied
    elementwise with the values in the window.
min_samples
    The number of values in the window that should be non-null before computing
    a result. If set to `None` (default), it will be set equal to `window_size`.
center
    Set the labels at the center of the window.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3, 4, 5])
>>> s.rolling_sum(window_size=2)
shape: (5,)
Series: 'a' [i64]
[
        null
        3
        5
        7
        9
]
Nr  r  s        r   rolling_sumSeries.rolling_sum  r  r   )rE  r  r  c                   g)u>  
Compute a rolling standard deviation based on another series.

.. warning::
    This functionality is considered **unstable**. It may be changed
    at any point without it being considered a breaking change.

Given a `by` column `<t_0, t_1, ..., t_n>`, then `closed="right"`
(the default) means the windows will be:

    - (t_0 - window_size, t_0]
    - (t_1 - window_size, t_1]
    - ...
    - (t_n - window_size, t_n]

Parameters
----------
by
    Should be ``DateTime``, ``Date``, ``UInt64``, ``UInt32``, ``Int64``,
    or ``Int32`` data type (note that the integral ones require using `'i'`
    in `window size`).
window_size
    The length of the window. Can be a dynamic temporal
    size indicated by a timedelta or the following string language:

    - 1ns   (1 nanosecond)
    - 1us   (1 microsecond)
    - 1ms   (1 millisecond)
    - 1s    (1 second)
    - 1m    (1 minute)
    - 1h    (1 hour)
    - 1d    (1 calendar day)
    - 1w    (1 calendar week)
    - 1mo   (1 calendar month)
    - 1q    (1 calendar quarter)
    - 1y    (1 calendar year)
    - 1i    (1 index count)

    By "calendar day", we mean the corresponding time on the next day
    (which may not be 24 hours, due to daylight savings). Similarly for
    "calendar week", "calendar month", "calendar quarter", and
    "calendar year".
min_samples
    The number of values in the window that should be non-null before computing
    a result.
closed : {'left', 'right', 'both', 'none'}
    Define which sides of the temporal interval are closed (inclusive),
    defaults to `'right'`.
ddof
    "Delta Degrees of Freedom": The divisor for a length N window is N - ddof

Notes
-----
If you want to compute multiple aggregation statistics over the same dynamic
window, consider using `rolling` - this method can cache the window size
computation.

Examples
--------
Create a series with a row index value

>>> from datetime import timedelta, datetime
>>> start = datetime(2001, 1, 1)
>>> stop = datetime(2001, 1, 2)
>>> s = pl.Series("index", range(25))
>>> s
shape: (25,)
Series: 'index' [i64]
[
    0
    1
    2
    3
    4
    …
    20
    21
    22
    23
    24
]

Create another series to apply the window mask:

>>> d = pl.Series("date", pl.datetime_range(start, stop, "1h", eager=True))
>>> d
shape: (25,)
Series: 'date' [datetime[μs]]
[
        2001-01-01 00:00:00
        2001-01-01 01:00:00
        2001-01-01 02:00:00
        2001-01-01 03:00:00
        2001-01-01 04:00:00
        …
        2001-01-01 20:00:00
        2001-01-01 21:00:00
        2001-01-01 22:00:00
        2001-01-01 23:00:00
        2001-01-02 00:00:00
]

Compute the rolling std with the temporal windows
from the second series closed on the right:

>>> s.rolling_std_by(d, "3h")
shape: (25,)
Series: 'index' [f64]
[
    null
    0.707107
    1.0
    1.0
    1.0
    …
    1.0
    1.0
    1.0
    1.0
    1.0
]
Nr  r   r  r  rE  r  r  s         r   rolling_std_bySeries.rolling_std_by  r  r   )rE  r  r  c                   g)a  
Compute a rolling std dev.

A window of length `window_size` will traverse the array. The values that fill
this window will (optionally) be multiplied with the weights given by the
`weight` vector. The resulting values will be aggregated to their std dev.

The window at a given row will include the row itself and the `window_size - 1`
elements before it.

.. versionchanged:: 1.21.0
    The `min_periods` parameter was renamed `min_samples`.

Parameters
----------
window_size
    The length of the window in number of elements.
weights
    An optional slice with the same length as the window that will be multiplied
    elementwise with the values in the window.
min_samples
    The number of values in the window that should be non-null before computing
    a result. If set to `None` (default), it will be set equal to `window_size`.
center
    Set the labels at the center of the window.
ddof
    "Delta Degrees of Freedom": The divisor for a length N window is N - ddof

Examples
--------
>>> s = pl.Series("a", [1.0, 2.0, 3.0, 4.0, 6.0, 8.0])
>>> s.rolling_std(window_size=3)
shape: (6,)
Series: 'a' [f64]
[
        null
        null
        1.0
        1.0
        1.527525
        2.0
]
Nr  r   r  r  rE  r  r  s         r   rolling_stdSeries.rolling_stdv  r  r   c                   g)u  
Compute a rolling variance based on another series.

.. warning::
    This functionality is considered **unstable**. It may be changed
    at any point without it being considered a breaking change.

Given a `by` column `<t_0, t_1, ..., t_n>`, then `closed="right"`
(the default) means the windows will be:

    - (t_0 - window_size, t_0]
    - (t_1 - window_size, t_1]
    - ...
    - (t_n - window_size, t_n]

Parameters
----------
by
    Should be ``DateTime``, ``Date``, ``UInt64``, ``UInt32``, ``Int64``,
    or ``Int32`` data type (note that the integral ones require using `'i'`
    in `window size`).
window_size
    The length of the window. Can be a dynamic temporal
    size indicated by a timedelta or the following string language:

    - 1ns   (1 nanosecond)
    - 1us   (1 microsecond)
    - 1ms   (1 millisecond)
    - 1s    (1 second)
    - 1m    (1 minute)
    - 1h    (1 hour)
    - 1d    (1 calendar day)
    - 1w    (1 calendar week)
    - 1mo   (1 calendar month)
    - 1q    (1 calendar quarter)
    - 1y    (1 calendar year)
    - 1i    (1 index count)

    By "calendar day", we mean the corresponding time on the next day
    (which may not be 24 hours, due to daylight savings). Similarly for
    "calendar week", "calendar month", "calendar quarter", and
    "calendar year".
min_samples
    The number of values in the window that should be non-null before computing
    a result.
closed : {'left', 'right', 'both', 'none'}
    Define which sides of the temporal interval are closed (inclusive),
    defaults to `'right'`.
ddof
    "Delta Degrees of Freedom": The divisor for a length N window is N - ddof

Notes
-----
If you want to compute multiple aggregation statistics over the same dynamic
window, consider using `rolling` - this method can cache the window size
computation.

Examples
--------
Create a series with a row index value

>>> from datetime import timedelta, datetime
>>> start = datetime(2001, 1, 1)
>>> stop = datetime(2001, 1, 2)
>>> s = pl.Series("index", range(25))
>>> s
shape: (25,)
Series: 'index' [i64]
[
    0
    1
    2
    3
    4
    …
    20
    21
    22
    23
    24
]

Create another series to apply the window mask:

>>> d = pl.Series("date", pl.datetime_range(start, stop, "1h", eager=True))
>>> d
shape: (25,)
Series: 'date' [datetime[μs]]
[
    2001-01-01 00:00:00
    2001-01-01 01:00:00
    2001-01-01 02:00:00
    2001-01-01 03:00:00
    2001-01-01 04:00:00
    …
    2001-01-01 20:00:00
    2001-01-01 21:00:00
    2001-01-01 22:00:00
    2001-01-01 23:00:00
    2001-01-02 00:00:00
]

Compute the rolling std with the temporal windows
from the second series closed on the right:

>>> s.rolling_std_by(d, "3h")
shape: (25,)
Series: 'index' [f64]
[
    null
    0.707107
    1.0
    1.0
    1.0
    …
    1.0
    1.0
    1.0
    1.0
    1.0
]
Nr  r  s         r   rolling_var_bySeries.rolling_var_by  r  r   c                   g)a  
Compute a rolling variance.

A window of length `window_size` will traverse the array. The values that fill
this window will (optionally) be multiplied with the weights given by the
`weight` vector. The resulting values will be aggregated to their variance.

The window at a given row will include the row itself and the `window_size - 1`
elements before it.

.. versionchanged:: 1.21.0
    The `min_periods` parameter was renamed `min_samples`.

Parameters
----------
window_size
    The length of the window in number of elements.
weights
    An optional slice with the same length as the window that will be multiplied
    elementwise with the values in the window.
min_samples
    The number of values in the window that should be non-null before computing
    a result. If set to `None` (default), it will be set equal to `window_size`.
center
    Set the labels at the center of the window.
ddof
    "Delta Degrees of Freedom": The divisor for a length N window is N - ddof

Examples
--------
>>> s = pl.Series("a", [1.0, 2.0, 3.0, 4.0, 6.0, 8.0])
>>> s.rolling_var(window_size=3)
shape: (6,)
Series: 'a' [f64]
[
        null
        null
        1.0
        1.0
        2.333333
        4.0
]
Nr  r  s         r   rolling_varSeries.rolling_var1  r  r   c                   g)a  
Compute a custom rolling window function.

.. warning::
    This functionality is considered **unstable**. It may be changed
    at any point without it being considered a breaking change.

.. versionchanged:: 1.21.0
    The `min_periods` parameter was renamed `min_samples`.

Parameters
----------
function
    Custom aggregation function.
window_size
    The length of the window in number of elements.
weights
    An optional slice with the same length as the window that will be multiplied
    elementwise with the values in the window.
min_samples
    The number of values in the window that should be non-null before computing
    a result. If set to `None` (default), it will be set equal to `window_size`.
center
    Set the labels at the center of the window.

Warnings
--------
Computing custom functions is extremely slow. Use specialized rolling
functions such as :func:`Series.rolling_sum` if at all possible.

Examples
--------
>>> from numpy import nansum
>>> s = pl.Series([11.0, 2.0, 9.0, float("nan"), 8.0])
>>> s.rolling_map(nansum, window_size=3)
shape: (5,)
Series: '' [f64]
[
        null
        null
        22.0
        11.0
        17.0
]
Nr  )r   r  r  r  rE  r  s         r   rolling_mapSeries.rolling_mapg  r  r   c                   g)u
  
Compute a rolling median based on another series.

.. warning::
    This functionality is considered **unstable**. It may be changed
    at any point without it being considered a breaking change.

Given a `by` column `<t_0, t_1, ..., t_n>`, then `closed="right"`
(the default) means the windows will be:

    - (t_0 - window_size, t_0]
    - (t_1 - window_size, t_1]
    - ...
    - (t_n - window_size, t_n]

Parameters
----------
by
    Should be ``DateTime``, ``Date``, ``UInt64``, ``UInt32``, ``Int64``,
    or ``Int32`` data type (note that the integral ones require using `'i'`
    in `window size`).
window_size
    The length of the window. Can be a dynamic temporal
    size indicated by a timedelta or the following string language:

    - 1ns   (1 nanosecond)
    - 1us   (1 microsecond)
    - 1ms   (1 millisecond)
    - 1s    (1 second)
    - 1m    (1 minute)
    - 1h    (1 hour)
    - 1d    (1 calendar day)
    - 1w    (1 calendar week)
    - 1mo   (1 calendar month)
    - 1q    (1 calendar quarter)
    - 1y    (1 calendar year)
    - 1i    (1 index count)

    By "calendar day", we mean the corresponding time on the next day
    (which may not be 24 hours, due to daylight savings). Similarly for
    "calendar week", "calendar month", "calendar quarter", and
    "calendar year".
min_samples
    The number of values in the window that should be non-null before computing
    a result.
closed : {'left', 'right', 'both', 'none'}
    Define which sides of the temporal interval are closed (inclusive),
    defaults to `'right'`.

Notes
-----
If you want to compute multiple aggregation statistics over the same dynamic
window, consider using `rolling` - this method can cache the window size
computation.

Examples
--------
Create a series with a row index value

>>> from datetime import timedelta, datetime
>>> start = datetime(2001, 1, 1)
>>> stop = datetime(2001, 1, 2)
>>> s = pl.Series("index", range(25))
>>> s
shape: (25,)
Series: 'index' [i64]
[
    0
    1
    2
    3
    4
    …
    20
    21
    22
    23
    24
]

Create another series to apply the window mask:

>>> d = pl.Series("date", pl.datetime_range(start, stop, "1h", eager=True))
>>> d
shape: (25,)
Series: 'date' [datetime[μs]]
[
    2001-01-01 00:00:00
    2001-01-01 01:00:00
    2001-01-01 02:00:00
    2001-01-01 03:00:00
    2001-01-01 04:00:00
    …
    2001-01-01 20:00:00
    2001-01-01 21:00:00
    2001-01-01 22:00:00
    2001-01-01 23:00:00
    2001-01-02 00:00:00
]

Compute the rolling median with the temporal windows
from the second series closed on the right:

>>> s.rolling_median_by(d, "3h")
shape: (25,)
Series: 'index' [f64]
[
    0.0
    0.5
    1.0
    2.0
    3.0
    …
    19.0
    20.0
    21.0
    22.0
    23.0
]
Nr  r  s        r   rolling_median_bySeries.rolling_median_by  r  r   c                   g)a  
Compute a rolling median.

.. warning::
    This functionality is considered **unstable**. It may be changed
    at any point without it being considered a breaking change.

The window at a given row will include the row itself and the `window_size - 1`
elements before it.

.. versionchanged:: 1.21.0
    The `min_periods` parameter was renamed `min_samples`.

Parameters
----------
window_size
    The length of the window in number of elements.
weights
    An optional slice with the same length as the window that will be multiplied
    elementwise with the values in the window.
min_samples
    The number of values in the window that should be non-null before computing
    a result. If set to `None` (default), it will be set equal to `window_size`.
center
    Set the labels at the center of the window.

Examples
--------
>>> s = pl.Series("a", [1.0, 2.0, 3.0, 4.0, 6.0, 8.0])
>>> s.rolling_median(window_size=3)
shape: (6,)
Series: 'a' [f64]
[
        null
        null
        2.0
        3.0
        4.0
        6.0
]
Nr  r  s        r   rolling_medianSeries.rolling_median"  r  r   )r  rE  r  c                   g)uf  
Compute a rolling quantile based on another series.

.. warning::
    This functionality is considered **unstable**. It may be changed
    at any point without it being considered a breaking change.

Given a `by` column `<t_0, t_1, ..., t_n>`, then `closed="right"`
(the default) means the windows will be:

    - (t_0 - window_size, t_0]
    - (t_1 - window_size, t_1]
    - ...
    - (t_n - window_size, t_n]

Parameters
----------
by
    Should be ``DateTime``, ``Date``, ``UInt64``, ``UInt32``, ``Int64``,
    or ``Int32`` data type (note that the integral ones require using `'i'`
    in `window size`).
quantile
    Quantile between 0.0 and 1.0.
interpolation : {'nearest', 'higher', 'lower', 'midpoint', 'linear', 'equiprobable'}
    Interpolation method.
window_size
    The length of the window. Can be a dynamic
    temporal size indicated by a timedelta or the following string language:

    - 1ns   (1 nanosecond)
    - 1us   (1 microsecond)
    - 1ms   (1 millisecond)
    - 1s    (1 second)
    - 1m    (1 minute)
    - 1h    (1 hour)
    - 1d    (1 calendar day)
    - 1w    (1 calendar week)
    - 1mo   (1 calendar month)
    - 1q    (1 calendar quarter)
    - 1y    (1 calendar year)
    - 1i    (1 index count)

    By "calendar day", we mean the corresponding time on the next day
    (which may not be 24 hours, due to daylight savings). Similarly for
    "calendar week", "calendar month", "calendar quarter", and
    "calendar year".
min_samples
    The number of values in the window that should be non-null before computing
    a result.
closed : {'left', 'right', 'both', 'none'}
    Define which sides of the temporal interval are closed (inclusive),
    defaults to `'right'`.

Notes
-----
If you want to compute multiple aggregation statistics over the same dynamic
window, consider using `rolling` - this method can cache the window size
computation.

Examples
--------
Create a series with a row index value

>>> from datetime import timedelta, datetime
>>> start = datetime(2001, 1, 1)
>>> stop = datetime(2001, 1, 2)
>>> s = pl.Series("index", range(25))
>>> s
shape: (25,)
Series: 'index' [i64]
[
    0
    1
    2
    3
    4
    …
    20
    21
    22
    23
    24
]

Create another series to apply the window mask:

>>> d = pl.Series("date", pl.datetime_range(start, stop, "1h", eager=True))
>>> d
shape: (25,)
Series: 'date' [datetime[μs]]
[
    2001-01-01 00:00:00
    2001-01-01 01:00:00
    2001-01-01 02:00:00
    2001-01-01 03:00:00
    2001-01-01 04:00:00
    …
    2001-01-01 20:00:00
    2001-01-01 21:00:00
    2001-01-01 22:00:00
    2001-01-01 23:00:00
    2001-01-02 00:00:00
]

Compute the rolling quantile with the temporal windows from the second series closed on the right:

>>> s.rolling_quantile_by(d, "3h", quantile=0.5)
shape: (25,)
Series: 'index' [f64]
[
    0.0
    1.0
    1.0
    2.0
    3.0
    …
    19.0
    20.0
    21.0
    22.0
    23.0
]
Nr  )r   r  r  r  r  rE  r  s          r   rolling_quantile_bySeries.rolling_quantile_byV  r  r   c                   g)aq  
Compute a rolling quantile.

The window at a given row will include the row itself and the `window_size - 1`
elements before it.

.. warning::
    This functionality is considered **unstable**. It may be changed
    at any point without it being considered a breaking change.

.. versionchanged:: 1.21.0
    The `min_periods` parameter was renamed `min_samples`.

Parameters
----------
quantile
    Quantile between 0.0 and 1.0.
interpolation : {'nearest', 'higher', 'lower', 'midpoint', 'linear', 'equiprobable'}
    Interpolation method.
window_size
    The length of the window in number of elements.
weights
    An optional slice with the same length as the window that will be multiplied
    elementwise with the values in the window.
min_samples
    The number of values in the window that should be non-null before computing
    a result. If set to `None` (default), it will be set equal to `window_size`.
center
    Set the labels at the center of the window.

Examples
--------
>>> s = pl.Series("a", [1.0, 2.0, 3.0, 4.0, 6.0, 8.0])
>>> s.rolling_quantile(quantile=0.33, window_size=3)
shape: (6,)
Series: 'a' [f64]
[
        null
        null
        2.0
        3.0
        4.0
        6.0
]
>>> s.rolling_quantile(quantile=0.33, interpolation="linear", window_size=3)
shape: (6,)
Series: 'a' [f64]
[
        null
        null
        1.66
        2.66
        3.66
        5.32
]
Nr  )r   r  r  r  r  rE  r  s          r   rolling_quantileSeries.rolling_quantile  r  r   )biasrE  r  c                   g)a  
Compute a rolling skew.

.. warning::
    This functionality is considered **unstable**. It may be changed
    at any point without it being considered a breaking change.

The window at a given row includes the row itself and the
`window_size - 1` elements before it.

Parameters
----------
window_size
    Integer size of the rolling window.
bias
    If False, the calculations are corrected for statistical bias.
min_samples
    The number of values in the window that should be non-null before computing
    a result. If set to `None` (default), it will be set equal to `window_size`.
center
    Set the labels at the center of the window.

See Also
--------
Series.skew

Examples
--------
>>> pl.Series([1, 4, 2, 9]).rolling_skew(3)
shape: (4,)
Series: '' [f64]
[
    null
    null
    0.381802
    0.47033
]

Note how the values match

>>> pl.Series([1, 4, 2]).skew(), pl.Series([4, 2, 9]).skew()
(0.38180177416060584, 0.47033046033698594)
Nr  )r   r  r   rE  r  s        r   rolling_skewSeries.rolling_skew"  r  r   )fisherr   rE  r  c                   g)a  
Compute a rolling kurtosis.

.. warning::
    This functionality is considered **unstable**. It may be changed
    at any point without it being considered a breaking change.

The window at a given row will include the row itself, and the `window_size - 1`
elements before it.

Parameters
----------
window_size
    Integer size of the rolling window.
fisher : bool, optional
    If True, Fisher's definition is used (normal ==> 0.0). If False,
    Pearson's definition is used (normal ==> 3.0).
bias : bool, optional
    If False, the calculations are corrected for statistical bias.
min_samples
    The number of values in the window that should be non-null before computing
    a result. If set to `None` (default), it will be set equal to `window_size`.
center
    Set the labels at the center of the window.

See Also
--------
Series.kurtosis

Examples
--------
>>> pl.Series([1, 4, 2, 9]).rolling_kurtosis(3)
shape: (4,)
Series: '' [f64]
[
    null
    null
    -1.5
    -1.5
]
Nr  )r   r  r  r   rE  r  s         r   rolling_kurtosisSeries.rolling_kurtosisW  r  r   )fractionwith_replacementshuffleseedc                   g)as  
Sample from this Series.

Parameters
----------
n
    Number of items to return. Cannot be used with `fraction`. Defaults to 1 if
    `fraction` is None.
fraction
    Fraction of items to return. Cannot be used with `n`.
with_replacement
    Allow values to be sampled more than once.
shuffle
    Shuffle the order of sampled data points.
seed
    Seed for the random number generator. If set to None (default), a
    random seed is generated for each sample operation.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3, 4, 5])
>>> s.sample(2, seed=0)  # doctest: +IGNORE_RESULT
shape: (2,)
Series: 'a' [i64]
[
    1
    5
]
Nr  )r   rt  r  r	  r
  r  s         r   sampleSeries.sample  r  r   c                    g)z
Get a boolean mask of the local maximum peaks.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3, 4, 5])
>>> s.peak_max()
shape: (5,)
Series: 'a' [bool]
[
        false
        false
        false
        false
        true
]
Nr  r   s    r   peak_maxSeries.peak_max  r  r   c                    g)z
Get a boolean mask of the local minimum peaks.

Examples
--------
>>> s = pl.Series("a", [4, 1, 3, 2, 5])
>>> s.peak_min()
shape: (5,)
Series: 'a' [bool]
[
    false
    true
    false
    true
    false
]
Nr  r   s    r   peak_minSeries.peak_min  r  r   c                6    U R                   R                  5       $ )z~
Count the number of unique values in this Series.

Examples
--------
>>> s = pl.Series("a", [1, 2, 2, 3])
>>> s.n_unique()
3
)r   n_uniquer   s    r   r  Series.n_unique  s     ww!!r   c                   U(       a  U R                   R                  5         U $ U R                  5       nUR                   R                  5         U$ )z
Shrink Series memory usage.

Shrinks the underlying array capacity to exactly fit the actual data.
(Note that this function does not change the Series data type).
)r   shrink_to_fitrf  )r   rw  r   s      r   r  Series.shrink_to_fit  s<     GG!!#KZZ\FII##%Mr   c                    g)a  
Hash the Series.

The hash value is of type `UInt64`.

Parameters
----------
seed
    Random seed parameter. Defaults to 0.
seed_1
    Random seed parameter. Defaults to `seed` if not set.
seed_2
    Random seed parameter. Defaults to `seed` if not set.
seed_3
    Random seed parameter. Defaults to `seed` if not set.

Notes
-----
This implementation of `hash` does not guarantee stable results
across different Polars versions. Its stability is only guaranteed within a
single version.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3])
>>> s.hash(seed=42)  # doctest: +IGNORE_RESULT
shape: (3,)
Series: 'a' [u64]
[
    10734580197236529959
    3022416320763508302
    13756996518000038261
]
Nr  )r   r  seed_1seed_2seed_3s        r   hashSeries.hash  r  r   )signedc                   g)a>  
Reinterpret the underlying bits as a signed/unsigned integer.

This operation is only allowed for 64bit integers. For lower bits integers,
you can safely use that cast operation.

Parameters
----------
signed
    If True, reinterpret as `pl.Int64`. Otherwise, reinterpret as `pl.UInt64`.

Examples
--------
>>> s = pl.Series("a", [-(2**60), -2, 3])
>>> s
shape: (3,)
Series: 'a' [i64]
[
        -1152921504606846976
        -2
        3
]
>>> s.reinterpret(signed=False)
shape: (3,)
Series: 'a' [u64]
[
        17293822569102704640
        18446744073709551614
        3
]
Nr  )r   r!  s     r   reinterpretSeries.reinterpret  r  r   c                    g)aL  
Interpolate intermediate values.

Nulls at the beginning and end of the series remain null.

Parameters
----------
method : {'linear', 'nearest'}
    Interpolation method.

Examples
--------
>>> s = pl.Series("a", [1, 2, None, None, 5])
>>> s.interpolate()
shape: (5,)
Series: 'a' [f64]
[
    1.0
    2.0
    3.0
    4.0
    5.0
]
Nr  )r   r  s     r   interpolateSeries.interpolate>  r  r   c                    g)a  
Interpolate intermediate values with x-coordinate based on another column.

Nulls at the beginning and end of the series remain null.

Parameters
----------
by
    Column to interpolate values based on.

Examples
--------
Fill null values using linear interpolation.

>>> s = pl.Series([1, None, None, 3])
>>> by = pl.Series([1, 2, 7, 8])
>>> s.interpolate_by(by)
shape: (4,)
Series: '' [f64]
[
    1.0
    1.285714
    2.714286
    3.0
]
Nr  r   r  s     r   interpolate_bySeries.interpolate_byX  r  r   c                    g)z
Compute absolute values.

Same as `abs(series)`.

Examples
--------
>>> s = pl.Series([1, -2, -3])
>>> s.abs()
shape: (3,)
Series: '' [i64]
[
    1
    2
    3
]
Nr  r   s    r   r;  
Series.abst  r  r   )r  r  c                   g)a  
Assign ranks to data, dealing with ties appropriately.

Parameters
----------
method : {'average', 'min', 'max', 'dense', 'ordinal', 'random'}
    The method used to assign ranks to tied elements.
    The following methods are available (default is 'average'):

    - 'average' : The average of the ranks that would have been assigned to
      all the tied values is assigned to each value.
    - 'min' : The minimum of the ranks that would have been assigned to all
      the tied values is assigned to each value. (This is also referred to
      as "competition" ranking.)
    - 'max' : The maximum of the ranks that would have been assigned to all
      the tied values is assigned to each value.
    - 'dense' : Like 'min', but the rank of the next highest element is
      assigned the rank immediately after those assigned to the tied
      elements.
    - 'ordinal' : All values are given a distinct rank, corresponding to
      the order that the values occur in the Series.
    - 'random' : Like 'ordinal', but the rank for ties is not dependent
      on the order that the values occur in the Series.
descending
    Rank in descending order.
seed
    If `method="random"`, use this as seed.

Examples
--------
The 'average' method:

>>> s = pl.Series("a", [3, 6, 1, 1, 6])
>>> s.rank()
shape: (5,)
Series: 'a' [f64]
[
    3.0
    4.5
    1.5
    1.5
    4.5
]

The 'ordinal' method:

>>> s = pl.Series("a", [3, 6, 1, 1, 6])
>>> s.rank("ordinal")
shape: (5,)
Series: 'a' [u32]
[
    3
    4
    1
    2
    5
]
Nr  )r   r  r  r  s       r   rankSeries.rank  r  r   c                    g)a  
Calculate the first discrete difference between shifted items.

Parameters
----------
n
    Number of slots to shift.
null_behavior : {'ignore', 'drop'}
    How to handle null values.

Examples
--------
>>> s = pl.Series("s", values=[20, 10, 30, 25, 35], dtype=pl.Int8)
>>> s.diff()
shape: (5,)
Series: 's' [i8]
[
    null
    -10
    20
    -5
    10
]

>>> s.diff(n=2)
shape: (5,)
Series: 's' [i8]
[
    null
    null
    10
    15
    5
]

>>> s.diff(n=2, null_behavior="drop")
shape: (3,)
Series: 's' [i8]
[
    10
    15
    5
]
Nr  )r   rt  null_behaviors      r   diffSeries.diff  r  r   c                    g)a  
Computes percentage change between values.

Percentage change (as fraction) between current element and most-recent
non-null element at least `n` period(s) before the current element.

Computes the change from the previous row by default.

Parameters
----------
n
    periods to shift for forming percent change.

Examples
--------
>>> pl.Series(range(10)).pct_change()
shape: (10,)
Series: '' [f64]
[
    null
    inf
    1.0
    0.5
    0.333333
    0.25
    0.2
    0.166667
    0.142857
    0.125
]

>>> pl.Series([1, 2, 4, 8, 16, 32, 64, 128, 256, 512]).pct_change(2)
shape: (10,)
Series: '' [f64]
[
    null
    null
    3.0
    3.0
    3.0
    3.0
    3.0
    3.0
    3.0
    3.0
]
Nr  rs  s     r   
pct_changeSeries.pct_change  r  r   )r   c               8    U R                   R                  U5      $ )a  
Compute the sample skewness of a data set.

For normally distributed data, the skewness should be about zero. For
unimodal continuous distributions, a skewness value greater than zero means
that there is more weight in the right tail of the distribution. The
function `skewtest` can be used to determine if the skewness value
is close enough to zero, statistically speaking.


See scipy.stats for more information.

Parameters
----------
bias : bool, optional
    If False, the calculations are corrected for statistical bias.

Notes
-----
The sample skewness is computed as the Fisher-Pearson coefficient
of skewness, i.e.

.. math:: g_1=\frac{m_3}{m_2^{3/2}}

where

.. math:: m_i=\frac{1}{N}\sum_{n=1}^N(x[n]-\bar{x})^i

is the biased sample :math:`i\texttt{th}` central moment, and
:math:`\bar{x}` is
the sample mean. If `bias` is False, the calculations are
corrected for bias and the value computed is the adjusted
Fisher-Pearson standardized moment coefficient, i.e.

.. math::
    G_1 = \frac{k_3}{k_2^{3/2}} = \frac{\sqrt{N(N-1)}}{N-2}\frac{m_3}{m_2^{3/2}}

Examples
--------
>>> s = pl.Series([1, 2, 2, 4, 5])
>>> s.skew()
0.34776706224699483
)r   skew)r   r   s     r   r9  Series.skew(  s    X ww||D!!r   )r  r   c               8    U R                   R                  X5      $ )a  
Compute the kurtosis (Fisher or Pearson) of a dataset.

Kurtosis is the fourth central moment divided by the square of the
variance. If Fisher's definition is used, then 3.0 is subtracted from
the result to give 0.0 for a normal distribution.
If bias is False then the kurtosis is calculated using k statistics to
eliminate bias coming from biased moment estimators

See scipy.stats for more information

Parameters
----------
fisher : bool, optional
    If True, Fisher's definition is used (normal ==> 0.0). If False,
    Pearson's definition is used (normal ==> 3.0).
bias : bool, optional
    If False, the calculations are corrected for statistical bias.

Examples
--------
>>> s = pl.Series("grades", [66, 79, 54, 97, 96, 70, 69, 85, 93, 75])
>>> s.kurtosis()
-1.0522623626787952
>>> s.kurtosis(fisher=False)
1.9477376373212048
>>> s.kurtosis(fisher=False, bias=False)
2.1040361802642717
)r   kurtosis)r   r  r   s      r   r<  Series.kurtosisV  s    < ww--r   c                    g)a  
Set values outside the given boundaries to the boundary value.

Parameters
----------
lower_bound
    Lower bound. Accepts expression input.
    Non-expression inputs are parsed as literals.
    If set to `None` (default), no lower bound is applied.
upper_bound
    Upper bound. Accepts expression input.
    Non-expression inputs are parsed as literals.
    If set to `None` (default), no upper bound is applied.

See Also
--------
when

Notes
-----
This method only works for numeric and temporal columns. To clip other data
types, consider writing a `when-then-otherwise` expression. See :func:`when`.

Examples
--------
Specifying both a lower and upper bound:

>>> s = pl.Series([-50, 5, 50, None])
>>> s.clip(1, 10)
shape: (4,)
Series: '' [i64]
[
        1
        5
        10
        null
]

Specifying only a single bound:

>>> s.clip(upper_bound=10)
shape: (4,)
Series: '' [i64]
[
        -50
        5
        10
        null
]
Nr  )r   r  r  s      r   clipSeries.clipv  r  r   c                    g)a  
Return the lower bound of this Series' dtype as a unit Series.

See Also
--------
upper_bound : return the upper bound of the given Series' dtype.

Examples
--------
>>> s = pl.Series("s", [-1, 0, 1], dtype=pl.Int32)
>>> s.lower_bound()
shape: (1,)
Series: 's' [i32]
[
    -2147483648
]

>>> s = pl.Series("s", [1.0, 2.5, 3.0], dtype=pl.Float32)
>>> s.lower_bound()
shape: (1,)
Series: 's' [f32]
[
    -inf
]
Nr  r   s    r   r  Series.lower_bound  r  r   c                    g)a  
Return the upper bound of this Series' dtype as a unit Series.

See Also
--------
lower_bound : return the lower bound of the given Series' dtype.

Examples
--------
>>> s = pl.Series("s", [-1, 0, 1], dtype=pl.Int8)
>>> s.upper_bound()
shape: (1,)
Series: 's' [i8]
[
    127
]

>>> s = pl.Series("s", [1.0, 2.5, 3.0], dtype=pl.Float64)
>>> s.upper_bound()
shape: (1,)
Series: 's' [f64]
[
    inf
]
Nr  r   s    r   r  Series.upper_bound  r  r   )defaultr  c                   g)a!  
Replace values by different values of the same data type.

Parameters
----------
old
    Value or sequence of values to replace.
    Also accepts a mapping of values to their replacement as syntactic sugar for
    `replace(old=Series(mapping.keys()), new=Series(mapping.values()))`.
new
    Value or sequence of values to replace by.
    Length must match the length of `old` or have length 1.

default
    Set values that were not replaced to this value.
    Defaults to keeping the original value.
    Accepts expression input. Non-expression inputs are parsed as literals.

    .. deprecated:: 0.20.31
        Use :meth:`replace_all` instead to set a default while replacing values.

return_dtype
    The data type of the resulting expression. If set to `None` (default),
    the data type is determined automatically based on the other inputs.

    .. deprecated:: 0.20.31
        Use :meth:`replace_all` instead to set a return data type while
        replacing values.


See Also
--------
replace_strict
str.replace

Notes
-----
The global string cache must be enabled when replacing categorical values.

Examples
--------
Replace a single value by another value. Values that were not replaced remain
unchanged.

>>> s = pl.Series([1, 2, 2, 3])
>>> s.replace(2, 100)
shape: (4,)
Series: '' [i64]
[
        1
        100
        100
        3
]

Replace multiple values by passing sequences to the `old` and `new` parameters.

>>> s.replace([2, 3], [100, 200])
shape: (4,)
Series: '' [i64]
[
        1
        100
        100
        200
]

Passing a mapping with replacements is also supported as syntactic sugar.

>>> mapping = {2: 100, 3: 200}
>>> s.replace(mapping)
shape: (4,)
Series: '' [i64]
[
        1
        100
        100
        200
]

The original data type is preserved when replacing by values of a different
data type. Use :meth:`replace_strict` to replace and change the return data
type.

>>> s = pl.Series(["x", "y", "z"])
>>> mapping = {"x": 1, "y": 2, "z": 3}
>>> s.replace(mapping)
shape: (3,)
Series: '' [str]
[
        "1"
        "2"
        "3"
]
Nr  r   oldnewrE  r  s        r   r'  Series.replace  r  r   c                   g)a  
Replace all values by different values.

Parameters
----------
old
    Value or sequence of values to replace.
    Also accepts a mapping of values to their replacement as syntactic sugar for
    `replace_strict(old=Series(mapping.keys()), new=Series(mapping.values()))`.
new
    Value or sequence of values to replace by.
    Length must match the length of `old` or have length 1.
default
    Set values that were not replaced to this value. If no default is specified,
    (default), an error is raised if any values were not replaced.
    Accepts expression input. Non-expression inputs are parsed as literals.
return_dtype
    The data type of the resulting Series. If set to `None` (default),
    the data type is determined automatically based on the other inputs.

Raises
------
InvalidOperationError
    If any non-null values in the original column were not replaced, and no
    `default` was specified.

See Also
--------
replace
str.replace

Notes
-----
The global string cache must be enabled when replacing categorical values.

Examples
--------
Replace values by passing sequences to the `old` and `new` parameters.

>>> s = pl.Series([1, 2, 2, 3])
>>> s.replace_strict([1, 2, 3], [100, 200, 300])
shape: (4,)
Series: '' [i64]
[
        100
        200
        200
        300
]

Passing a mapping with replacements is also supported as syntactic sugar.

>>> mapping = {1: 100, 2: 200, 3: 300}
>>> s.replace_strict(mapping)
shape: (4,)
Series: '' [i64]
[
        100
        200
        200
        300
]

By default, an error is raised if any non-null values were not replaced.
Specify a default to set all values that were not matched.

>>> mapping = {2: 200, 3: 300}
>>> s.replace_strict(mapping)  # doctest: +SKIP
Traceback (most recent call last):
...
polars.exceptions.InvalidOperationError: incomplete mapping specified for `replace_strict`
>>> s.replace_strict(mapping, default=-1)
shape: (4,)
Series: '' [i64]
[
        -1
        200
        200
        300
]

The default can be another Series.

>>> default = pl.Series([2.5, 5.0, 7.5, 10.0])
>>> s.replace_strict(2, 200, default=default)
shape: (4,)
Series: '' [f64]
[
        2.5
        200.0
        200.0
        10.0
]

Replacing by values of a different data type sets the return type based on
a combination of the `new` data type and the `default` data type.

>>> s = pl.Series(["x", "y", "z"])
>>> mapping = {"x": 1, "y": 2, "z": 3}
>>> s.replace_strict(mapping)
shape: (3,)
Series: '' [i64]
[
        1
        2
        3
]
>>> s.replace_strict(mapping, default="x")
shape: (3,)
Series: '' [str]
[
        "1"
        "2"
        "3"
]

Set the `return_dtype` parameter to control the resulting data type directly.

>>> s.replace_strict(mapping, return_dtype=pl.UInt8)
shape: (3,)
Series: '' [u8]
[
        1
        2
        3
]
Nr  rG  s        r   replace_strictSeries.replace_strictL   r  r   c                V    U R                  U R                  R                  U5      5      $ )aZ  
Reshape this Series to a flat Series or an Array Series.

Parameters
----------
dimensions
    Tuple of the dimension sizes. If a -1 is used in any of the dimensions, that
    dimension is inferred.

Returns
-------
Series
    If a single dimension is given, results in a Series of the original
    data type.
    If a multiple dimensions are given, results in a Series of data type
    :class:`Array` with shape `dimensions`.

See Also
--------
Series.list.explode : Explode a list column.

Examples
--------
>>> s = pl.Series("foo", [1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> square = s.reshape((3, 3))
>>> square
shape: (3,)
Series: 'foo' [array[i64, 3]]
[
        [1, 2, 3]
        [4, 5, 6]
        [7, 8, 9]
]
>>> square.reshape((9,))
shape: (9,)
Series: 'foo' [i64]
[
        1
        2
        3
        4
        5
        6
        7
        8
        9
]
)r   r   reshape)r   
dimensionss     r   rO  Series.reshape   s#    b ""477??:#>??r   c                    g)aQ  
Shuffle the contents of this Series.

Parameters
----------
seed
    Seed for the random number generator. If set to None (default), a
    random seed is generated each time the shuffle is called.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3])
>>> s.shuffle(seed=1)
shape: (3,)
Series: 'a' [i64]
[
        2
        3
        1
]
Nr  )r   r  s     r   r
  Series.shuffle!  r  r   )comspan	half_lifealphaadjustrE  r  c                   g)a	  
Compute exponentially-weighted moving average.

.. versionchanged:: 1.21.0
    The `min_periods` parameter was renamed `min_samples`.

Parameters
----------
com
    Specify decay in terms of center of mass, :math:`\gamma`, with

        .. math::
            \alpha = \frac{1}{1 + \gamma} \; \forall \; \gamma \geq 0
span
    Specify decay in terms of span, :math:`\theta`, with

        .. math::
            \alpha = \frac{2}{\theta + 1} \; \forall \; \theta \geq 1
half_life
    Specify decay in terms of half-life, :math:`\tau`, with

        .. math::
            \alpha = 1 - \exp \left\{ \frac{ -\ln(2) }{ \tau } \right\} \;
            \forall \; \tau > 0
alpha
    Specify smoothing factor alpha directly, :math:`0 < \alpha \leq 1`.
adjust
    Divide by decaying adjustment factor in beginning periods to account for
    imbalance in relative weightings

        - When `adjust=True` (the default) the EW function is calculated
          using weights :math:`w_i = (1 - \alpha)^i`
        - When `adjust=False` the EW function is calculated
          recursively by

          .. math::
            y_0 &= x_0 \\
            y_t &= (1 - \alpha)y_{t - 1} + \alpha x_t
min_samples
    Minimum number of observations in window required to have a value
    (otherwise result is null).
ignore_nulls
    Ignore missing values when calculating weights.

        - When `ignore_nulls=False` (default), weights are based on absolute
          positions.
          For example, the weights of :math:`x_0` and :math:`x_2` used in
          calculating the final weighted average of
          [:math:`x_0`, None, :math:`x_2`] are
          :math:`(1-\alpha)^2` and :math:`1` if `adjust=True`, and
          :math:`(1-\alpha)^2` and :math:`\alpha` if `adjust=False`.

        - When `ignore_nulls=True`, weights are based
          on relative positions. For example, the weights of
          :math:`x_0` and :math:`x_2` used in calculating the final weighted
          average of [:math:`x_0`, None, :math:`x_2`] are
          :math:`1-\alpha` and :math:`1` if `adjust=True`,
          and :math:`1-\alpha` and :math:`\alpha` if `adjust=False`.

Examples
--------
>>> s = pl.Series([1, 2, 3])
>>> s.ewm_mean(com=1, ignore_nulls=False)
shape: (3,)
Series: '' [f64]
[
        1.0
        1.666667
        2.428571
]
Nr  )r   rT  rU  rV  rW  rX  rE  r  s           r   ewm_meanSeries.ewm_mean!  r  r   c                   g)a  
Compute time-based exponentially weighted moving average.

Given observations :math:`x_0, x_1, \ldots, x_{n-1}` at times
:math:`t_0, t_1, \ldots, t_{n-1}`, the EWMA is calculated as

    .. math::

        y_0 &= x_0

        \alpha_i &= 1 - \exp \left\{ \frac{ -\ln(2)(t_i-t_{i-1}) }
            { \tau } \right\}

        y_i &= \alpha_i x_i + (1 - \alpha_i) y_{i-1}; \quad i > 0

where :math:`\tau` is the `half_life`.

Parameters
----------
by
    Times to calculate average by. Should be ``DateTime``, ``Date``, ``UInt64``,
    ``UInt32``, ``Int64``, or ``Int32`` data type.
half_life
    Unit over which observation decays to half its value.

    Can be created either from a timedelta, or
    by using the following string language:

    - 1ns   (1 nanosecond)
    - 1us   (1 microsecond)
    - 1ms   (1 millisecond)
    - 1s    (1 second)
    - 1m    (1 minute)
    - 1h    (1 hour)
    - 1d    (1 day)
    - 1w    (1 week)
    - 1i    (1 index count)

    Or combine them:
    "3d12h4m25s" # 3 days, 12 hours, 4 minutes, and 25 seconds

    Note that `half_life` is treated as a constant duration - calendar
    durations such as months (or even days in the time-zone-aware case)
    are not supported, please express your duration in an approximately
    equivalent number of hours (e.g. '370h' instead of '1mo').

Returns
-------
Expr
    Float32 if input is Float32, otherwise Float64.

Examples
--------
>>> from datetime import date, timedelta
>>> df = pl.DataFrame(
...     {
...         "values": [0, 1, 2, None, 4],
...         "times": [
...             date(2020, 1, 1),
...             date(2020, 1, 3),
...             date(2020, 1, 10),
...             date(2020, 1, 15),
...             date(2020, 1, 17),
...         ],
...     }
... ).sort("times")
>>> df["values"].ewm_mean_by(df["times"], half_life="4d")
shape: (5,)
Series: 'values' [f64]
[
        0.0
        0.292893
        1.492474
        null
        3.254508
]
Nr  )r   r  rV  s      r   ewm_mean_bySeries.ewm_mean_byr!  r  r   )rT  rU  rV  rW  rX  r   rE  r  c                   g)au	  
Compute exponentially-weighted moving standard deviation.

.. versionchanged:: 1.21.0
    The `min_periods` parameter was renamed `min_samples`.

Parameters
----------
com
    Specify decay in terms of center of mass, :math:`\gamma`, with

        .. math::
            \alpha = \frac{1}{1 + \gamma} \; \forall \; \gamma \geq 0
span
    Specify decay in terms of span, :math:`\theta`, with

        .. math::
            \alpha = \frac{2}{\theta + 1} \; \forall \; \theta \geq 1
half_life
    Specify decay in terms of half-life, :math:`\lambda`, with

        .. math::
            \alpha = 1 - \exp \left\{ \frac{ -\ln(2) }{ \lambda } \right\} \;
            \forall \; \lambda > 0
alpha
    Specify smoothing factor alpha directly, :math:`0 < \alpha \leq 1`.
adjust
    Divide by decaying adjustment factor in beginning periods to account for
    imbalance in relative weightings

        - When `adjust=True` (the default) the EW function is calculated
          using weights :math:`w_i = (1 - \alpha)^i`
        - When `adjust=False` the EW function is calculated
          recursively by

          .. math::
            y_0 &= x_0 \\
            y_t &= (1 - \alpha)y_{t - 1} + \alpha x_t
bias
    When `bias=False`, apply a correction to make the estimate statistically
    unbiased.
min_samples
    Minimum number of observations in window required to have a value
    (otherwise result is null).
ignore_nulls
    Ignore missing values when calculating weights.

        - When `ignore_nulls=False` (default), weights are based on absolute
          positions.
          For example, the weights of :math:`x_0` and :math:`x_2` used in
          calculating the final weighted average of
          [:math:`x_0`, None, :math:`x_2`] are
          :math:`(1-\alpha)^2` and :math:`1` if `adjust=True`, and
          :math:`(1-\alpha)^2` and :math:`\alpha` if `adjust=False`.

        - When `ignore_nulls=True`, weights are based
          on relative positions. For example, the weights of
          :math:`x_0` and :math:`x_2` used in calculating the final weighted
          average of [:math:`x_0`, None, :math:`x_2`] are
          :math:`1-\alpha` and :math:`1` if `adjust=True`,
          and :math:`1-\alpha` and :math:`\alpha` if `adjust=False`.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3])
>>> s.ewm_std(com=1, ignore_nulls=False)
shape: (3,)
Series: 'a' [f64]
[
    0.0
    0.707107
    0.963624
]
Nr  	r   rT  rU  rV  rW  rX  r   rE  r  s	            r   ewm_stdSeries.ewm_std!  r  r   c                   g)af	  
Compute exponentially-weighted moving variance.

.. versionchanged:: 1.21.0
    The `min_periods` parameter was renamed `min_samples`.

Parameters
----------
com
    Specify decay in terms of center of mass, :math:`\gamma`, with

        .. math::
            \alpha = \frac{1}{1 + \gamma} \; \forall \; \gamma \geq 0
span
    Specify decay in terms of span, :math:`\theta`, with

        .. math::
            \alpha = \frac{2}{\theta + 1} \; \forall \; \theta \geq 1
half_life
    Specify decay in terms of half-life, :math:`\lambda`, with

        .. math::
            \alpha = 1 - \exp \left\{ \frac{ -\ln(2) }{ \lambda } \right\} \;
            \forall \; \lambda > 0
alpha
    Specify smoothing factor alpha directly, :math:`0 < \alpha \leq 1`.
adjust
    Divide by decaying adjustment factor in beginning periods to account for
    imbalance in relative weightings

        - When `adjust=True` (the default) the EW function is calculated
          using weights :math:`w_i = (1 - \alpha)^i`
        - When `adjust=False` the EW function is calculated
          recursively by

          .. math::
            y_0 &= x_0 \\
            y_t &= (1 - \alpha)y_{t - 1} + \alpha x_t
bias
    When `bias=False`, apply a correction to make the estimate statistically
    unbiased.
min_samples
    Minimum number of observations in window required to have a value
    (otherwise result is null).
ignore_nulls
    Ignore missing values when calculating weights.

        - When `ignore_nulls=False` (default), weights are based on absolute
          positions.
          For example, the weights of :math:`x_0` and :math:`x_2` used in
          calculating the final weighted average of
          [:math:`x_0`, None, :math:`x_2`] are
          :math:`(1-\alpha)^2` and :math:`1` if `adjust=True`, and
          :math:`(1-\alpha)^2` and :math:`\alpha` if `adjust=False`.

        - When `ignore_nulls=True`, weights are based
          on relative positions. For example, the weights of
          :math:`x_0` and :math:`x_2` used in calculating the final weighted
          average of [:math:`x_0`, None, :math:`x_2`] are
          :math:`1-\alpha` and :math:`1` if `adjust=True`,
          and :math:`1-\alpha` and :math:`\alpha` if `adjust=False`.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3])
>>> s.ewm_var(com=1, ignore_nulls=False)
shape: (3,)
Series: 'a' [f64]
[
    0.0
    0.5
    0.928571
]
Nr  r`  s	            r   ewm_varSeries.ewm_var"  r  r   c                    g)a  
Extremely fast method for extending the Series with 'n' copies of a value.

Parameters
----------
value
    A constant literal value or a unit expression with which to extend the
    expression result Series; can pass None to extend with nulls.
n
    The number of additional values that will be added.

Examples
--------
>>> s = pl.Series([1, 2, 3])
>>> s.extend_constant(99, n=2)
shape: (5,)
Series: '' [i64]
[
        1
        2
        3
        99
        99
]
Nr  )r   ri  rt  s      r   r`  Series.extend_constantv"  r  r   c               V    U R                  U R                  R                  U5      5      $ )a_  
Flags the Series as 'sorted'.

Enables downstream code to user fast paths for sorted arrays.

Parameters
----------
descending
    If the `Series` order is descending.

Warnings
--------
This can lead to incorrect results if this `Series` is not sorted!!
Use with care!

Examples
--------
>>> s = pl.Series("a", [1, 2, 3])
>>> s.set_sorted().max()
3
)r   r   set_sorted_flag)r   r  s     r   
set_sortedSeries.set_sorted"  s$    , ""477#:#::#FGGr   c                V    U R                  U R                  R                  X5      5      $ )z
Create a new Series filled with values from the given index.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3, 4, 5])
>>> s.new_from_index(1, 3)
shape: (3,)
Series: 'a' [i64]
[
    2
    2
    2
]
)r   r   new_from_index)r   r  rg  s      r   rm  Series.new_from_index"  s$      ""477#9#9%#HIIr   c                H    [        U R                  R                  5       5      $ )a  
Shrink numeric columns to the minimal required datatype.

Shrink to the dtype needed to fit the extrema of this [`Series`].
This can be used to reduce memory pressure.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3, 4, 5, 6])
>>> s
shape: (6,)
Series: 'a' [i64]
[
        1
        2
        3
        4
        5
        6
]
>>> s.shrink_dtype()
shape: (6,)
Series: 'a' [i8]
[
        1
        2
        3
        4
        5
        6
]
)r0   r   shrink_dtyper   s    r   rp  Series.shrink_dtype"  s    B dgg**,--r   c                6    U R                   R                  5       $ )aN  
Get the chunks of this Series as a list of Series.

Examples
--------
>>> s1 = pl.Series("a", [1, 2, 3])
>>> s2 = pl.Series("a", [4, 5, 6])
>>> s = pl.concat([s1, s2], rechunk=False)
>>> s.get_chunks()
[shape: (3,)
Series: 'a' [i64]
[
        1
        2
        3
], shape: (3,)
Series: 'a' [i64]
[
        4
        5
        6
]]
)r   
get_chunksr   s    r   rs  Series.get_chunks"  s    0 ww!!##r   c                    g)z
Aggregate values into a list.

Examples
--------
>>> s = pl.Series("a", [1, 2, 3])
>>> s.implode()
shape: (1,)
Series: 'a' [list[i64]]
[
    [1, 2, 3]
]
Nr  r   s    r   rI  Series.implode"  r  r   c                    g)z Evaluate the number of set bits.Nr  r   s    r   bitwise_count_onesSeries.bitwise_count_ones#  r  r   c                    g)z"Evaluate the number of unset Self.Nr  r   s    r   bitwise_count_zerosSeries.bitwise_count_zeros
#  r  r   c                    g)zIEvaluate the number most-significant set bits before seeing an unset bit.Nr  r   s    r   bitwise_leading_onesSeries.bitwise_leading_ones#  r  r   c                    g)zHEvaluate the number most-significant unset bits before seeing a set bit.Nr  r   s    r   bitwise_leading_zerosSeries.bitwise_leading_zeros#  r  r   c                    g)zJEvaluate the number least-significant set bits before seeing an unset bit.Nr  r   s    r   bitwise_trailing_onesSeries.bitwise_trailing_ones#  r  r   c                    g)zIEvaluate the number least-significant unset bits before seeing a set bit.Nr  r   s    r   bitwise_trailing_zerosSeries.bitwise_trailing_zeros#  r  r   c                6    U R                   R                  5       $ )z'Perform an aggregation of bitwise ANDs.)r   bitwise_andr   s    r   r  Series.bitwise_and#      ww""$$r   c                6    U R                   R                  5       $ )z&Perform an aggregation of bitwise ORs.)r   
bitwise_orr   s    r   r  Series.bitwise_or#  s    ww!!##r   c                6    U R                   R                  5       $ )z'Perform an aggregation of bitwise XORs.)r   bitwise_xorr   s    r   r  Series.bitwise_xor!#  r  r   c                6    U R                   R                  5       $ )zN
Get the first element of the Series.

Returns `None` if the Series is empty.
)r   firstr   s    r   r  Series.first%#  s     ww}}r   c                6    U R                   R                  5       $ )zM
Get the last element of the Series.

Returns `None` if the Series is empty.
)r   lastr   s    r   r  Series.last-#  s     ww||~r   c                6    U R                   R                  5       $ )zq
Approximate count of unique values.

This is done using the HyperLogLog++ algorithm for cardinality estimation.
)r   approx_n_uniquer   s    r   r  Series.approx_n_unique5#  s     ww&&((r   	unorderedr  r  c                   U R                  5       R                  [        R                  " U R                  5      R                  XUS95      R                  5       $ )zEncode to the row encoding.r  )r  r  r=  r  r   _row_encoder  )r   r  r  r  s       r   r  Series._row_encode=#  sJ     MMOZdii ,,': - 
 Y[	
r   c          
         U R                  5       R                  [        R                  " U R                  5      R                  UUUUUS95      R                  5       $ )zDecode from the row encoding.r  )r  r  r=  r  r   _row_decoder  )r   namesdtypesr  r  r  s         r   r  Series._row_decodeO#  sT     MMOZdii ,,')) -  Y[	
r   c                    g)a  
Repeat the elements in this Series as specified in the given expression.

The repeated elements are expanded into a List.

Parameters
----------
by
    Numeric column that determines how often the values will be repeated.
    The column will be coerced to UInt32. Give this dtype to make the coercion
    a no-op.

Returns
-------
Expr
    Expression of data type List, where the inner data type is equal to the
    original data type.
Nr  r)  s     r   	repeat_bySeries.repeat_byg#  r  r   c                    [        U 5      $ )z9Create an object namespace of all binary related methods.r]   r   s    r   r   
Series.bin~#       t$$r   c                    [        U 5      $ )z>Create an object namespace of all categorical related methods.r_   r   s    r   r   
Series.cat#  s     D!!r   c                    [        U 5      $ )z;Create an object namespace of all datetime related methods.ra   r   s    r   r   	Series.dt#  s     !&&r   c                    [        U 5      $ )z7Create an object namespace of all list related methods.rc   r   s    r   r   Series.list#  s     T""r   c                    [        U 5      $ )z8Create an object namespace of all array related methods.r[   r   s    r   r   
Series.arr#  s     d##r   c                    [        U 5      $ )z9Create an object namespace of all string related methods.rf   r   s    r   r   
Series.str#  r  r   c                    [        U 5      $ )z9Create an object namespace of all struct related methods.rh   r   s    r   r   Series.struct#  r  r   c                    [         (       a  [        [        R                  5      S:  a  Sn[	        U5      e[        U 5      $ )a  
Create a plot namespace.

.. warning::
    This functionality is currently considered **unstable**. It may be
    changed at any point without it being considered a breaking change.

.. versionchanged:: 1.6.0
    In prior versions of Polars, HvPlot was the plotting backend. If you would
    like to restore the previous plotting functionality, all you need to do
    is add `import hvplot.polars` at the top of your script and replace
    `df.plot` with `df.hvplot`.

Polars does not implement plotting logic itself, but instead defers to
Altair:

- `s.plot.hist(**kwargs)`
  is shorthand for
  `alt.Chart(s.to_frame()).mark_bar(tooltip=True).encode(x=alt.X(f'{s.name}:Q', bin=True), y='count()', **kwargs).interactive()`
- `s.plot.kde(**kwargs)`
  is shorthand for
  `alt.Chart(s.to_frame()).transform_density(s.name, as_=[s.name, 'density']).mark_area(tooltip=True).encode(x=s.name, y='density:Q', **kwargs).interactive()`
- for any other attribute `attr`, `s.plot.attr(**kwargs)`
  is shorthand for
  `alt.Chart(s.to_frame().with_row_index()).mark_attr(tooltip=True).encode(x='index', y=s.name, **kwargs).interactive()`

For configuration, we suggest reading
`Chart Configuration <https://altair-viz.github.io/altair-tutorial/notebooks/08-Configuration.html>`_.
For example, you can:

- Change the width/height/title with ``.properties(width=500, height=350, title="My amazing plot")``.
- Change the x-axis label rotation with ``.configure_axisX(labelAngle=30)``.
- Change the opacity of the points in your scatter plot with ``.configure_point(opacity=.5)``.

Examples
--------
Histogram:

>>> s = pl.Series([1, 4, 4, 6, 2, 4, 3, 5, 5, 7, 1])
>>> s.plot.hist()  # doctest: +SKIP

KDE plot:

>>> s.plot.kde()  # doctest: +SKIP

Line plot:

>>> s.plot.line()  # doctest: +SKIP
)r;     r   z%altair>=5.4.0 is required for `.plot`)rK   r)   rQ   rF  rX   re   r  s     r   r   Series.plot#  s8    h ! M&2D2D$E	$Q9C,S11$r   )r   )NNN)r   zstr | ArrayLike | Noner   zArrayLike | Noner   PolarsDataType | Noner   re  r   re  r  None)r   rm   r  r   )r   r   r   zlist[tuple[int, int]]r  r   )r   r  r  r   )r   r  r   r  r  r  )r  rv   )r  r   )r   r   r   rv   r   r   r  r   r   )r   r   r   zSeries | Sequence[Series]r   zSeries | Noner  r   )r  r  )r  rr   )r  zdict[str, bool])r  r   )r  z
tuple[int])r  r   )r  bytes)r"  r  r  r  )r6  rs   r  rs   )r6  r   r  r   )r6  r   r  zExpr | Series)r6  r   ro  rx   r  r   )r6  rE  r  r   )r6  rE  r  Series | Expr)r6  r   r  r  )r6  r   r  r   r  r   r  r   )r6  rq   r  rq   )r6  r   r  r   )r6  r   r  zSeries | DataFrame | Expr)r  r   r  r   )r  r   )r%  zint | float | Seriesr  r   )r6  r   r  zfloat | Series | None)r  r   )rD  r  r  r   )rK  r   r  re  )r  zGenerator[Any])rZ  r   r  r   )rZ  r}   r  r   )rZ  z(SingleIndexSelector | MultiIndexSelectorr  zAny | Series)rZ  zFint | Series | np.ndarray[Any, Any] | Sequence[object] | tuple[object]ri  r   r  r  )NN)r   znpt.DTypeLike | Noners  bool | Noner  r   )
r  znp.ufuncr  r   r  r   r~  r   r  r   )r  zobject | Noner  rE  )r  
int | Noner  r   )r   )r  r   r  int | float)r  zLiteral[True]r  re  )r  re  r  r  )r  zfloat | Seriesr  r   )r   
str | Noner  rq   ))g      ?g      ?g      ?r  )r  zSequence[float] | float | Noner  r   r  rq   )r  r  )r  zPythonLiteral | None)r  z/int | float | date | datetime | timedelta | str)r%  )r  r  r  zfloat | timedelta | None)r  )r  rg  r  r   r  float | None)r  r   r  re  r  re  r  rq   )
r  zSequence[float]r  Sequence[str] | Noner  re  r  re  r  r   )r"  zSequence[float] | intr  r  r  re  r   re  r  re  r  r   )
r/  list[float] | Noner+  r  r,  re  r-  re  r  rq   )
r4  re  r5  re  r   r  r6  re  r  rq   )r  rg  r6  re  r  r  )rI  rs   rE  r  r5  re  r  r   )r   r   r  r   )r  z	list[int])rU  re  r  r   )rU  re  r  r   )rU  r  rg  r  r  r   )r6  r   r  r   )ro  zSeries | Iterable[bool]r  r   )
   )rt  r  r  r   )r   )rt  r  rU  r  r  r   )
r  re  r  re  r  re  rw  re  r  r   )r;  )r   r  r  r   )r  zIntoExpr | Iterable[IntoExpr]r   r  rU  zbool | Sequence[bool]r  r   )r  re  r  re  r  r   )r  r  ).)r  zNonNestedLiteral | Noner  r   r  re  r  r  )r  zDlist[NonNestedLiteral | None] | np.ndarray[Any, Any] | Expr | Seriesr  r   r  re  r  r   )r  )r  z&IntoExpr | np.ndarray[Any, Any] | Noner  r   r  re  r  zint | Series)r  re  r  r   )r  z6int | list[int] | Expr | Series | np.ndarray[Any, Any]r  r   )r  re  )r  re  r  re  r  re  )r6  zSeries | Collection[Any]r  re  r  r   )
r6  r   r  re  r  re  r  re  r  re  )r   z/type[int | float | str | bool] | PolarsDataTyper   re  r  re  r  r   )r  z	list[Any])rw  re  r  r   )r  )r  r{   r  r{   r  rw   r  r   )
r6  r{   r  rg  r  rg  r  re  r  r   )
rn  re  ro  re  r  r  r  r  r  r   )r(  zjax.Device | str | Noner  z	jax.Array)r  ztorch.Tensor)r5  zCompatLevel | Noner  r   )r9  re  r~  r   r  r   )i  )rt  r  r  r   )r  r   ri  zint | float | str | bool | Noner  r   )r  z3Series | Iterable[int] | int | np.ndarray[Any, Any]r   z7Series | Iterable[PythonLiteral] | PythonLiteral | Noner  r   )r  r{   r  r  )ri  zint | float | Expr | Noner  r   )ri  zAny | Expr | Nonerh  zFillNullStrategy | Noner{  r  r  r   )r{  r  r  r   )r   half_to_even)r}  r  r~  r   r  r   )r  r  r  r   )r6  zSeries | ArrayLiker  zint | float | None)r  zCallable[[Any], Any]r  r  r  re  r  r   )rt  r  r  zIntoExpr | Noner  r   )r  r   r6  r   r  r   )
r  r{   r  timedelta | strrE  r  r  rw   r  r   )
r  r  r  r  rE  r  r  re  r  r   )r  r{   r  r  rE  r  r  rw   r  r  r  r   )r  r  r  r  rE  r  r  re  r  r  r  r   )r  zCallable[[Series], Any]r  r  r  r  rE  r  r  re  r  r   )r  r{   r  r  r  rg  r  r   rE  r  r  rw   r  r   )r     N)r  rg  r  r   r  r  r  r  rE  r  r  re  r  r   )
r  r  r   re  rE  r  r  re  r  r   )r  r  r  re  r   re  rE  r  r  re  r  r   )rt  r  r  r  r	  re  r
  re  r  r  r  r   )rw  re  r  r   )r   NNN)
r  r  r  r  r  r  r  r  r  r   )r!  re  r  r   )linear)r  rz   r  r   )r  r{   r  r   )average)r  r   r  re  r  r  r  r   )r%  ignore)rt  r  r2  r   r  r   )rt  int | IntoExprColumnr  r   )r   re  r  r  )r  re  r   re  r  r  )r  8NumericLiteral | TemporalLiteral | IntoExprColumn | Noner  r  r  r   )
rH  z,IntoExpr | Sequence[Any] | Mapping[Any, Any]rI  z$IntoExpr | Sequence[Any] | NoDefaultrE  zIntoExpr | NoDefaultr  r  r  r   )rP  ztuple[int, ...]r  r   )r  r  r  r   )rT  r  rU  r  rV  r  rW  r  rX  re  rE  r  r  re  r  r   )r  r{   rV  zstr | timedeltar  r   )rT  r  rU  r  rV  r  rW  r  rX  re  r   re  rE  r  r  re  r  r   )ri  r{   rt  r  r  r   )r  re  r  r   )r  r  rg  r  r  r   )r  zlist[Series])r  re  r  r  r  r  r  r   )r  zSequence[str]r  zSequence[PolarsDataType]r  re  r  Sequence[bool] | Noner  r  r  r   )r  r  r  r   )r  r^   )r  r`   )r  rb   )r  rd   )r  r\   )r  rg   )r  ri   )r  re   (+  r   
__module____qualname____firstlineno____doc__r   __annotations__r   r   classmethodr   r!   r   r   r   r   r   r   r   r   staticmethodr  propertyr   r  r   r  r  r  r!  r*  r-  r1  r   r7  rB  rJ  rQ  rV  r\  rt  rw  r~  r  r  r  r  r  r  ra  r  r  r  r  r  r  r  r  r  r  r  r  r  r	  r  r  r  r  r  r   r&  r*  r/  r2  r5  r8  r<  r@  rE  rL  rV  r[  rg  rr  r  r   r  rK  r  r  r  r  r  mather  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)  r0  r;  r>  rB  r    rJ  r)  r  rQ  r  rX  r[  r^  ra  rd  rQ  r  rl  r  rr  rx  r{  r~  r4  r  r  r  r  r  r  r  r  r  r  r  r  rH  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  rR  r  rU  r	  r  rp  r,  r2  r  rK  rQ  r9  r  rb  r   r\  r_  rf  re  ri  rp  rt  rw  rz  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  r  r  r  r  r  r  r  r  r  r  r  r  r  r#  r&  r*  r;  r/  r3  r6  r9  r<  r?  r  r  r(   r'  rL  rO  r
  rZ  r]  ra  rd  r`  rj  rm  rp  rs  rI  rx  r{  r~  r  r  r  r  r  r  r  r  r  r  r  r  r   r   r   r   r   r   r   r   __static_attributes__r  r   r   r   r      sB   K\ B	&J" 	 (,#''+	h! !h!$h! !h! %	h! h! h! 
h!T  
 	VQ	 
Q Q Q( = =<:*,
< T"T1;TDGT	T T> 
 #'	5
5
 (5
  	5

 
5
 5
n . . 
 
  $ 
 
 
  
 
&$I / /0 0= 0 01 1 . ./ /< / /0 0 / /0 0= 0 01 1L-\ . .2 2' . .2 2( . ./ /' . ./ /' . ./ /* . ./ /* * *+ +" * *+ +" * *+ +" 2 23 3'VR * *+ +" 2 23 3'VR * *+ +" * *+ +")-V 9 9/ /. .	8 / /. .8;  3 34 484 4 45 5Q / /9 90 0< / /0 08<<<
7<8"
I 9
E ? ?A A1;1	1<)!S)! )! 
	)!X GK*)*8C*	*Xs+s+'*s+58s+DGs+	s+j< <>/ /6$% $%L66 36D D< <*. #6 #6J 36D D< <*. #6 #6J *. """"88&/ &/T 7I(1F:3F: &F: 
	F:P*
!&*VX

M&M&! !&! !&
  @I99.<9	90   .N .N 	.N
 .N 
.N` Z
 (,!$GG %	G
 G G 
G GR Z
 (,!!&$[([ %	[
 [ [ [ 
[ [z@%N Z $(>' !%!%#'>' >' 	>'
 >' !>' 
>' >'F R
 R
 	R

 R
 R
 
R
h" %)FF 
 
 
: Z xP01E***-*=A*	* Q *X2 2'*". */  , */  , +0  6 */  6 ,1  .P P2*X8tA<&4 &4P&4 &4P& &P B ! "2 2 	2
 2 2 
2h" "N 0
 */0)0 0
 '0 
0d" "N 0
 */0)0 0
 '0 
0d .3u  >*! !   "%
 ( 
  
   "%
 U 
  
  "'@
 !@7@ @
 @ 
@D 05  ,M	.
$# 	<#	#
 /4 9 9.3.....08 "	D'D 	D
 
DL-*.00.$L !>9M
 #!,
,
 	,

 ,
 ,
 
,
 N,
d $+P>+P 	+P
 +P 
+PZ$L!  +0 %. %.N* "(	NN N 	N
 
Nh  88 	8
 8 8 
8z #'&*vJ vJ 	vJ
 !vJ $vJ 
vJp Z/ / /b Z. .` !>5I=A #1 #1 J#1L 6;X.2XFIX	Xt N  ND. $18f>D> H> 
	>@>*+< +<Z42D $(,0 	< < *< 	<
 
<|@ @&? ?&&&' 'R,%0"8$$$$""""$*""( /3]

  ]
&]
 ,]

 ]
 
]
 ]
~8 8 8t-H^ Z !( %
   
 B !xP '+/
 #'// $/
  / / 
/ Q/b Z !( %
   
 B !xP '+/
 #'// $/
  / / 
/ Q/b Z !( %
   
 B !xP '+/
 #'// $/
  / / 
/ Q/b Z !( %
   
 B !xP '+/
 #'// $/
  / / 
/ Q/b Z !(BB %B
 B B B 
B BH !xP '+3
 #'33 $3
  3 3 3 
3 Q3j Z !(BB %B
 B B B 
B BH !xP '+3
 #'33 $3
  3 3 3 
3 Q3j Z xP
 '+	5 #'5)5 5 $	5  5 5 
5 Q 5n Z !( %
   
 B Z xP '+0
 #'00 $0
  0 0 
0 Q 0d Z )2!(DD %D
 D &D D D 
D DL Z xP )2&*A #'AA &A 	A
 $A  A A 
A Q AF Z
 "&22 	2
  2 2 
2 2h Z
 "&11 	1
 1  1 1 
1 1j % "&!&%% 	%
 % % % 
% %N&&
" 16  " !!!(( ( 	(
 ( 
(T -1  B 48* '@ !@@ 	@
 @ 
@ @D, ,\/ /b $( ," ,"\ *.D . .D QUPT6M6 N6 
	6 6p6< 5?f
 )3.2f9f 2f
 &f ,f 
f fV 5?F
 )3.2F9F 2F
 &F ,F 
F FP1@f . !xP !!"&""Q Q 	Q
  Q Q Q Q Q 
Q QQfRR #	R
 
Rh !xP !!"&""U U 	U
  U U U U U U 
U QUn !xP !!"&""U U 	U
  U U U U U U 
U QUn6 05 H H0J$!.F$4/1XWYX%$%)  "&"&
 
  	

  
 

 
.  ,0,0

 )

 
 *
 *
 

 
0. % % " " ' ' # # $ $ % % % % Z5   5 r   c                   UR                   [        R                  :X  a  [        O[        nU b  U [        :X  a  [        U SS5      (       d  [        U SS5      =(       d    [        R                  " U5      S   nUS:X  a
  U" S5      n U $ US:X  a
  U" S5      n U $ US:X  a
  U" S5      n U $ US:X  a$  UR                   [        R                  :X  a  [        n U $ )z@Given polars/numpy temporal dtypes, resolve to an explicit unit.Nrk  r   nsrc  msD)	r   r   r   r6   r5   rm  datetime_datar   r4   )r   ndtype
PolarsTyperk  s       r   r   r   #  s    
 $[[BNN:J}(*75+t3T3TE;5T9I9I&9QRS9T	 t$E L $t$E
 L	 $t$E L #&++">ELr   )r   r  r  z2np.dtype[np.datetime64] | np.dtype[np.timedelta64]r  r  )
__future__r   
contextlibr  r#  syscollections.abcr   r   r   r   r   r	   r
   decimalr   r  typingr   r   r   r   r   r   r   r   polars._reexport	_reexportr   polarsr   r=  polars._utils.constructionr   r   r   r   r   r   r   polars._utils.convertr   r   r   r   polars._utils.deprecationr    r!   r"   polars._utils.getitemr$   polars._utils.unstabler%   polars._utils.variousr&   r'   r(   r)   r*   r+   r,   r-   r.   polars._utils.wrapr/   r0   polars.datatypesr1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   polars.datatypes._utilsrJ   polars.dependenciesrK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   r   rU   r   rV   r   polars.exceptionsrW   rX   rY   polars.interchange.protocolrZ   polars.series.arrayr\   polars.series.binaryr^   polars.series.categoricalr`   polars.series.datetimerb   polars.series.listrd   polars.series.plottingre   polars.series.stringrg   polars.series.structri   polars.series.utilsrj   rk   suppressImportErrorpolars._plrrl   rm   _plrplrrn   ro   rp   r  numpy.typingnptrq   rr   rs   polars._typingrt   ru   rv   rw   rx   ry   rz   r{   r|   r}   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   version_infor   typing_extensionswarningsmodulesr   current_moduler  	ArrayLiker   r   r  r   r   <module>r     s   "   	 
 . " 4 4 (	 	 	  !    
 9 +
 
 
 /      8 7
 
 
 , , - R R 3 . 0 2 4 , - 0 0 ;%1 & 			[	)! 
* ?>00      2 0
7"*
7"'0 [[*N-NSM
	 aL  aL  aL HY > U[ &% 
*	)s   *	JJ
J
J!