K i_\ddlmZmZmZmZmZmZmZmZm Z m Z m Z m Z m Z mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;mZ>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNddlOmPZPddlQZQddlRmSZSddlTZTddlUZVddlUmWZWddlXmYZYdZZePdd Z[d Z\d Z]d Z^d Z_dZ`dZadZbdZceceddxZeZfd!dZgd"dddZhddddZidZjd#dddZkd#dddZldddddZmdZnd Zoy)$)NFunctionFunctionOptionsFunctionRegistryHashAggregateFunctionHashAggregateKernelKernelScalarAggregateFunctionScalarAggregateKernelScalarFunction ScalarKernelVectorFunction VectorKernelArraySortOptionsAssumeTimezoneOptions CastOptions CountOptionsCumulativeOptionsCumulativeSumOptionsDayOfWeekOptionsDictionaryEncodeOptionsRunEndEncodeOptionsElementWiseAggregateOptionsExtractRegexOptionsExtractRegexSpanOptions FilterOptions IndexOptions JoinOptionsListSliceOptionsListFlattenOptionsMakeStructOptionsMapLookupOptionsMatchSubstringOptions ModeOptions NullOptions PadOptionsPairwiseOptionsPartitionNthOptionsPivotWiderOptionsQuantileOptions RandomOptions RankOptionsRankQuantileOptionsReplaceSliceOptionsReplaceSubstringOptionsRoundBinaryOptions RoundOptionsRoundTemporalOptionsRoundToMultipleOptionsScalarAggregateOptionsSelectKOptionsSetLookupOptions SkewOptions SliceOptions SortOptions SplitOptionsSplitPatternOptionsStrftimeOptionsStrptimeOptionsStructFieldOptions TakeOptionsTDigestOptions TrimOptionsUtf8NormalizeOptionsVarianceOptions WeekOptionsWinsorizeOptionsZeroFillOptions call_functionfunction_registry get_functionlist_functionscall_tabular_functionregister_scalar_functionregister_tabular_functionregister_aggregate_functionregister_vector_function UdfContext Expression) namedtupleN)dedent)_compute_docstrings) docscrapec.|jjSN)_doc arg_names)funcs U/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/pyarrow/compute.py_get_arg_namesr[qs 99  _OptionsClassDoc)paramscv|jsytj|j}t|dS)N Parameters)__doc__rTNumpyDocStringr]) options_classdocs rZ_scrape_options_class_docrexs4    " "=#8#8 9C C - ..r\c |j}t|j|j|j|j |_||_||_g}|j}|s%|jdkDrdnd}d|jd|}|j|d|j}|r|j|dtjj|j} |jtd t!|} | D]=} |j"d vrd } nd } |j| d | d|jd?|6t%|} | rc| j&D]S}|j|jd |j(d|j*D]}|jd|dUnt-j.d|jdt0t3j4|}|j6j9D]D}|jtd|jd|jd|jdF|jtd|jd|jtd| /t| j;d}|jd|ddj=||_|S)N)namearityrcoptions_required argumentsargumentzCall compute function z with the given z. z z. Parameters ---------- )vectorscalar_aggregatez Array-likezArray-like or scalar-likez :  z" Argument to compute function. z zOptions class z does not have a docstringz z. : optional Parameter for z7 constructor. Either `options` or `z@` can be passed, but not both at the same time. z& options : pyarrow.compute.zK, optional Alternative way of passing options. z memory_pool : pyarrow.MemoryPool, optional If not passed, will allocate memory from the default memory pool. ) rWdictrgrhrcri__arrow_compute_function____name__ __qualname__summaryappend descriptionrSfunction_doc_additionsgetrRr[kindrer^typedescwarningswarnRuntimeWarninginspect signature parametersvaluesstripjoinra)wrapper exposed_namerYrccpp_doc doc_piecesruarg_strrw doc_additionrXarg_namearg_typeoptions_class_docps options_sigstrippeds rZ_decorate_compute_functionrsiiG)- YYjj++ 11 *3G& $G'GJooG !%a+Z*499-7GyQ '(%%K[M./&==AA$))LLf   t$IA 996 6#H2HXJc(267?@ A 5mD &-- 4!!QVVHCxr":;4A%%QCrl34 4 MMN=+A+A*BC678F H!++M:K ++224 !!&.##0#9#9":;!*#  &&''4'='=&>? "  f   ,'--d3Bxj+,ggj)GO Nr\c|jj}|sy t|S#t$r!t j d|dt YywxYw)NzPython binding for z not exposed)rWrcglobalsKeyErrorr}r~r)rY class_names rZ_get_options_classrsV((J y$$  +J<|D$ &s ('AAc |s|r|td|d||i|S|Ct|tr|di|St||r|Std|d|dt|y)Nz Function z@ called with both an 'options' argument and additional argumentsz expected a z parameter, got ) TypeError isinstancerqr{)rgrcoptionsargskwargss rZ_handle_optionsrs v  D8$+,- -d-f-- gt $ +7+ +  /Nx|M?;=/ #$ $ r\cB ddfd }|Sdddfd }|S)N memory_poolc tur+t|k7rtddt|d|r2t|dtrt j t |Sj|d|S)N takes  positional argument(s), but were givenr)EllipsislenrrrP_calllistcall)rrrhrY func_names rZrz&_make_generic_wrapper..wrappersH$Te); k0t9+[2 47J7!'' 4:>>99T45 5r\)rrc 2tur6t|krtddt|d|d}|d}nd}t|||}|r3t |dt r t j t||Sj|||S)Nrrrrr) rrrrrrPrrr) rrrr option_argsrhrYrrcs rZrz&_make_generic_wrapper..wrappersH$t9u$#$+WUG4"4yk6#56l FU| %i&16;G 47J7!'' 4:wGG99T7K8 8r\r)rrYrcrhrs```` rZ_make_generic_wrapperrs5'+ 6 64 N!(,T 9 9 Nr\cddlm}g}|D]$}|j|||j&|D]$}|j|||j&|tj |}|j jD]W}|j|j|jfvsJ|r|j|j}|j|Y|j|d|jd|j|d|jdtj|S)Nr) Parameter)rzr)defaultr) rrrvPOSITIONAL_ONLYVAR_POSITIONALrrrrzPOSITIONAL_OR_KEYWORD KEYWORD_ONLYreplace Signature)rX var_arg_namesrcrr^rgrrs rZ_make_signaturers6! FB ii&?&?@ABA ii&>&>?@A '' 6 ''..0 A66i=='4466 66II9#9#9I: MM!     i 9+A+A(,. / MM)M9+A+A$(*+   V $$r\ct|}t|}|xr|djd}|r!|jj dg}ng}t ||||j }t||||_t||||S)N*)rh) rr[ startswithpoplstriprrhr __signature__r)rgrYrcrX has_varargrrs rZ_wrap_functionr(s&t,Mt$I>> from datetime import datetime >>> import pyarrow as pa >>> arr = pa.array([datetime(2010, 1, 1), datetime(2015, 1, 1)]) >>> arr.type TimestampType(timestamp[us]) You can use ``pyarrow.DataType`` objects to specify the target type: >>> cast(arr, pa.timestamp('ms')) [ 2010-01-01 00:00:00.000, 2015-01-01 00:00:00.000 ] >>> cast(arr, pa.timestamp('ms')).type TimestampType(timestamp[ms]) Alternatively, it is also supported to use the string aliases for these types: >>> arr.cast('timestamp[ms]') [ 2010-01-01 00:00:00.000, 2015-01-01 00:00:00.000 ] >>> arr.cast('timestamp[ms]').type TimestampType(timestamp[ms]) Returns ------- casted : Array The cast result as a new Array NzRMust either pass values for 'target_type' and 'safe' or pass a value for 'options'Fcast) ValueErrorpatypeslib ensure_typerunsafesaferF)arr target_typerrrsafe_vars_passeds rZrrZslD(Fk.EW0:; ;hhll..{; 5=!((5G!&&{3G # ==r\rcb|*||j|||z }n&|j|}n||jd|}t|tjs"tj||j }nH|j |j k7r/tj|j |j }t|}td|g||}|M|j dk\r:tj|j |ztj}|S)a Find the index of the first occurrence of a given value. Parameters ---------- data : Array-like value : Scalar-like object The value to search for. start : int, optional end : int, optional memory_pool : MemoryPool, optional If not passed, will allocate memory from the default memory pool. Returns ------- index : int the index, or -1 if not found Examples -------- >>> import pyarrow as pa >>> import pyarrow.compute as pc >>> arr = pa.array(["Lorem", "ipsum", "dolor", "sit", "Lorem", "ipsum"]) >>> pc.index(arr, "ipsum") >>> pc.index(arr, "ipsum", start=2) >>> pc.index(arr, "amet") rr{valueindex) slicerrScalarscalarr{as_pyrrFint64)datarstartendrrresults rZrrs>  ?::eS5[1D::e$D zz!S! eRYY ' %dii0 ejj  %++-dii8'G 7TFG[ AF V\\^q06<<>E1 C Mr\T) boundscheckrc:t|}td||g||S)a Select values (or records) from array- or table-like data given integer selection indices. The result will be of the same type(s) as the input, with elements taken from the input array (or record batch / table fields) at the given indices. If an index is null then the corresponding value in the output will be null. Parameters ---------- data : Array, ChunkedArray, RecordBatch, or Table indices : Array, ChunkedArray Must be of integer type boundscheck : boolean, default True Whether to boundscheck the indices. If False and there is an out of bounds index, will likely cause the process to crash. memory_pool : MemoryPool, optional If not passed, will allocate memory from the default memory pool. Returns ------- result : depends on inputs Selected values for the given indices Examples -------- >>> import pyarrow as pa >>> arr = pa.array(["a", "b", "c", None, "e", "f"]) >>> indices = pa.array([0, None, 4, 3]) >>> arr.take(indices) [ "a", null, "e", null ] )rtake)r>rF)rindicesrrrs rZrrs$Pk2G $'; GGr\cdt|tjtjtjfs"tj ||j }nH|j |j k7r/tj |j|j }td||gS)aeReplace each null element in values with a corresponding element from fill_value. If fill_value is scalar-like, then every null element in values will be replaced with fill_value. If fill_value is array-like, then the i-th element in values will be replaced with the i-th element in fill_value. The fill_value's type must be the same as that of values, or it must be able to be implicitly casted to the array's type. This is an alias for :func:`coalesce`. Parameters ---------- values : Array, ChunkedArray, or Scalar-like object Each null element is replaced with the corresponding value from fill_value. fill_value : Array, ChunkedArray, or Scalar-like object If not same type as values, will attempt to cast. Returns ------- result : depends on inputs Values with all null elements replaced Examples -------- >>> import pyarrow as pa >>> arr = pa.array([1, 2, None, 3], type=pa.int8()) >>> fill_value = pa.scalar(5, type=pa.int8()) >>> arr.fill_null(fill_value) [ 1, 2, 5, 3 ] >>> arr = pa.array([1, 2, None, 4, None]) >>> arr.fill_null(pa.array([10, 20, 30, 40, 50])) [ 1, 2, 30, 4, 50 ] rcoalesce) rrArray ChunkedArrayrrr{rrF)r fill_values rZ fill_nullrsuf j288R__bii"H IYYz <   'YYz//1 D fj%9 ::r\c|g}t|tjtjfr|j dn t d|}t ||}td|g||S)a Select the indices of the top-k ordered elements from array- or table-like data. This is a specialization for :func:`select_k_unstable`. Output is not guaranteed to be stable. Parameters ---------- values : Array, ChunkedArray, RecordBatch, or Table Data to sort and get top indices from. k : int The number of `k` elements to keep. sort_keys : List-like Column key names to order by when input is table-like data. memory_pool : MemoryPool, optional If not passed, will allocate memory from the default memory pool. Returns ------- result : Array Indices of the top-k ordered elements Examples -------- >>> import pyarrow as pa >>> import pyarrow.compute as pc >>> arr = pa.array(["a", "b", "c", None, "e", "f"]) >>> pc.top_k_unstable(arr, k=3) [ 5, 4, 2 ] )dummy descendingc |dfS)Nrrkey_names rZz top_k_unstable..bs (L)Ar\select_k_unstablerrrrrvmapr4rFrk sort_keysrrs rZtop_k_unstabler8scJ &288R__5601A9M Q *G ,vh MMr\c|g}t|tjtjfr|j dn t d|}t ||}td|g||S)a Select the indices of the bottom-k ordered elements from array- or table-like data. This is a specialization for :func:`select_k_unstable`. Output is not guaranteed to be stable. Parameters ---------- values : Array, ChunkedArray, RecordBatch, or Table Data to sort and get bottom indices from. k : int The number of `k` elements to keep. sort_keys : List-like Column key names to order by when input is table-like data. memory_pool : MemoryPool, optional If not passed, will allocate memory from the default memory pool. Returns ------- result : Array of indices Indices of the bottom-k ordered elements Examples -------- >>> import pyarrow as pa >>> import pyarrow.compute as pc >>> arr = pa.array(["a", "b", "c", None, "e", "f"]) >>> pc.bottom_k_unstable(arr, k=3) [ 0, 1, 2 ] )r ascendingc |dfS)Nrrrs rZrz#bottom_k_unstable..s (K)@r\rrrs rZbottom_k_unstablergscJ &288R__56/0@)L Q *G ,vh MMr\system) initializerrrc:t|}tdg|||S)aB Generate numbers in the range [0, 1). Generated values are uniformly-distributed, double-precision in range [0, 1). Algorithm and seed can be changed via RandomOptions. Parameters ---------- n : int Number of values to generate, must be greater than or equal to 0 initializer : int or str How to initialize the underlying random generator. If an integer is given, it is used as a seed. If "system" is given, the random generator is initialized with a system-specific source of (hopefully true) randomness. Other values are invalid. options : pyarrow.compute.RandomOptions, optional Alternative way of passing options. memory_pool : pyarrow.MemoryPool, optional If not passed, will allocate memory from the default memory pool. )rrandom)length)r*rF)nrrrs rZr r s!, 4G 2w A FFr\c8t|}|dk(rvt|dttfrt j |dSt|dt rt j|dStdt|dt j|S)aReference a column of the dataset. Stores only the field's name. Type and other information is known only when the expression is bound to a dataset having an explicit scheme. Nested references are allowed by passing multiple names or a tuple of names. For example ``('foo', 'bar')`` references the field named "bar" inside the field named "foo". Parameters ---------- *name_or_index : string, multiple strings, tuple or int The name or index of the (possibly nested) field the expression references to. Returns ------- field_expr : Expression Reference to the given field Examples -------- >>> import pyarrow.compute as pc >>> pc.field("a") >>> pc.field(1) >>> pc.field(("a", "b")) >> pc.field("a", "b") r?r@rArBrCrDrErFrGrHrIrJrKrLrMrNrOrP collectionsrQrtextwraprRr}pyarrowrrSpyarrow.vendoredrTr[r]rerrrrrrrr utf8_zfillrrrrrrrr rrrr\rZrsO$SSSSSSSSSSSSSSSSSSSSj#'&0+>/Pf (>%. J ;:%i(899 ^B>J/D/d(,)HX8;v,NT,N^,N,N^&tG4.7b%r\