
    y-Ph^                     N   d dl 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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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-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZM d dlNmOZO d dlPZPd dlQmRZR d dlSZSd dlTZUd dlTmVZV d dlWmXZX d ZY eOdd	          ZZd
 Z[d Z\d Z]d Z^d Z_d Z`d Zad Zb eb             d dZcd!dddZdddddZed Zfd"dddZgd"dddZhdddddZid Zjd ZkdS )#    )MFunctionFunctionOptionsFunctionRegistryHashAggregateFunctionHashAggregateKernelKernelScalarAggregateFunctionScalarAggregateKernelScalarFunctionScalarKernelVectorFunctionVectorKernelArraySortOptionsAssumeTimezoneOptionsCastOptionsCountOptionsCumulativeOptionsCumulativeSumOptionsDayOfWeekOptionsDictionaryEncodeOptionsRunEndEncodeOptionsElementWiseAggregateOptionsExtractRegexOptionsExtractRegexSpanOptionsFilterOptionsIndexOptionsJoinOptionsListSliceOptionsListFlattenOptionsMakeStructOptionsMapLookupOptionsMatchSubstringOptionsModeOptionsNullOptions
PadOptionsPairwiseOptionsPartitionNthOptionsPivotWiderOptionsQuantileOptionsRandomOptionsRankOptionsRankQuantileOptionsReplaceSliceOptionsReplaceSubstringOptionsRoundBinaryOptionsRoundOptionsRoundTemporalOptionsRoundToMultipleOptionsScalarAggregateOptionsSelectKOptionsSetLookupOptionsSkewOptionsSliceOptionsSortOptionsSplitOptionsSplitPatternOptionsStrftimeOptionsStrptimeOptionsStructFieldOptionsTakeOptionsTDigestOptionsTrimOptionsUtf8NormalizeOptionsVarianceOptionsWeekOptionsWinsorizeOptionscall_functionfunction_registryget_functionlist_functionscall_tabular_functionregister_scalar_functionregister_tabular_functionregister_aggregate_functionregister_vector_function
UdfContext
Expression)
namedtupleN)dedent)_compute_docstrings)	docscrapec                     | j         j        S N)_doc	arg_names)funcs    O/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/pyarrow/compute.py_get_arg_namesrZ   p   s    9    _OptionsClassDoc)paramsc                 p    | j         sd S t          j        | j                   }t          |d                   S )N
Parameters)__doc__rS   NumpyDocStringr\   )options_classdocs     rY   _scrape_options_class_docrd   w   s8      t

"=#8
9
9CC-...r[   c           	         |j         }t          |j        |j        |j        |j                  | _        || _        || _        g }|j	        }|s*|j        dk    rdnd}d
                    |j        |          }|                    | d           |j        }|r|                    | d           t          j                            |j                  }	|                    t!          d                     t#          |          }
|
D ]@}|j        d	v rd
}nd}|                    | d| d           |                    d           A|"t'          |          }|rS|j        D ]J}|                    |j         d|j         d           |j        D ]}|                    d| d           Knt/          j        d|j         dt2                     t5          j        |          }|j                                        D ]B}|                    t!          d
                    |j        |j                                       C|                    t!          d|j         d                     |                    t!          d                     |	H|                    d
                    t!          |	                              d                               d                    |          | _         | S )N)namearityrb   options_required   	argumentsargumentz,Call compute function {!r} with the given {}z.

z

z.        Parameters
        ----------
        )vectorscalar_aggregatez
Array-likezArray-like or scalar-likez : 
z"    Argument to compute function.
z    zOptions class z does not have a docstringz                {0} : optional
                    Parameter for {1} constructor. Either `options`
                    or `{0}` 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.
        z
{}
 )!rV   dictrf   rg   rb   rh   __arrow_compute_function____name____qualname__summaryformatappenddescriptionrR   function_doc_additionsgetrQ   rZ   kindrd   r]   typedescwarningswarnRuntimeWarninginspect	signature
parametersvaluesstripjoinr`   )wrapperexposed_namerX   rb   cpp_doc
doc_piecesrt   arg_strrw   doc_additionrW   arg_namearg_typeoptions_class_docpsoptions_sigs                    rY   _decorate_compute_functionr   ~   s    iG)-Yj+ 1	*3 *3 *3G&
 $G'GJ oG 0!%a++ZAF49g.. 	 '''((( %K 0[...///&=AA$)LLL f       t$$I A A9666#HH2HX66(666777?@@@@  5mDD 	=&- 4 4!!QV":":":":":;;; 4 4A%%lQlll333344
 M 7=+A 7 7 78FH H H!+M::K +2244 = =!!& * F16=#9::	#< #< = = = =
 	& "'4'=" " "   	 	 	
 f       (//&*>*>*D*DT*J*JKKLLLggj))GONr[   c                     | j         j        }|sd S 	 t                      |         S # t          $ r1 t	          j        d                    |          t                     Y d S w xY w)Nz!Python binding for {} not exposed)rV   rb   globalsKeyErrorr}   r~   ru   r   )rX   
class_names     rY   _get_options_classr      su    (J tyy$$   9vj))>	; 	; 	;tts   & 7A! A!c           	      *   |s|r,|"t          d                    |                      ||i |S |`t          |t                    r |di |S t          ||          r|S t          d                    | |t	          |                              d S )NzMFunction {!r} called with both an 'options' argument and additional argumentsz-Function {!r} expected a {} parameter, got {} )	TypeErrorru   
isinstancerp   r{   )rf   rb   optionsargskwargss        rY   _handle_optionsr      s     .v .+   }d-f---gt$$ 	 =++7+++// 	N;VD-g779 9 	9 4r[   c                 @     d d fd
}nd d d fd
}|S )Nmemory_poolc           	      2   t           ur8t          |          k    r%t           d dt          |           d          |r=t          |d         t                    r"t	          j        t          |                    S                     |d |           S )N takes  positional argument(s), but  were givenr   )Ellipsislenr   r   rO   _calllistcall)r   r   rg   rX   	func_names     rY   r   z&_make_generic_wrapper.<locals>.wrapper   s    H$$Te););  2 2 2 2t992 2 2    ?
47J77 ?!'	4::>>>99T4555r[   )r   r   c           	         t           urMt          |          k     r%t           d dt          |           d          |d          }|d          }nd}t          |||          }|r>t	          |d         t
                    r#t          j        t          |          |          S                     |||           S )Nr   r   r   r   r   )	r   r   r   r   r   rO   r   r   r   )	r   r   r   r   option_argsrg   rX   r   rb   s	        rY   r   z&_make_generic_wrapper.<locals>.wrapper   s    H$$t99u$$#$ 6 6U 6 6"4yy6 6 6   #566lFUF| %i&16; ;G H
47J77 H!'	4::wGGG99T7K888r[   r   )r   rX   rb   rg   r   s   ```` rY   _make_generic_wrapperr      s    '+ 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 (,T 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9  Nr[   c                 l   ddl m} g }| D ]&}|                     |||j                             '|D ]&}|                     |||j                             '|t          j        |          }|j                                        D ]K}|j        |j	        |j
        fv sJ |r|                    |j
                  }|                    |           L|                     |d|j
        d                      |                     |d|j
        d                      t          j        |          S )Nr   )	Parameter)rz   r   )defaultr   )r   r   rv   POSITIONAL_ONLYVAR_POSITIONALr   r   r   rz   POSITIONAL_OR_KEYWORDKEYWORD_ONLYreplace	Signature)rW   var_arg_namesrb   r   r]   rf   r   r   s           rY   _make_signaturer     s   !!!!!!F B Biii&?@@AAAA A Aiii&>??@@@@ '66'..00 	 	A6i='46 6 6 6 6 ;II9#9I::MM!ii	9+A(,. . . 	/ 	/ 	/
MM))M9+A$(* * * + + +V$$$r[   c                 R   t          |          }t          |          }|o|d                             d          }|r)|                                                    d          g}ng }t          | |||j                  }t          |||          |_        t          || ||          S )N*)rg   )
r   rZ   
startswithpoplstripr   rg   r   __signature__r   )rf   rX   rb   rW   
has_varargr   r   s          rY   _wrap_functionr   (  s    &t,,Mt$$I<y}77<<J "//445#dM5 5 5G+I},9; ;G%gtT=IIIr[   c                  ^   t                      } t                      }ddd}|                                D ]v}|                    ||          }|                    |          }|j        dk    r9|j        dk    r|j        dk    rP|| vs
J |            t          ||          x| |<   | |<   wdS )z
    Make global functions wrapping each compute function.

    Note that some of the automatically-generated wrappers may be overridden
    by custom versions below.
    and_or_)andorhash_aggregaterm   r   N)r   rF   rH   ry   rG   rz   rg   r   )gregrewritescpp_namerf   rX   s         rY   _make_global_functionsr   8  s     			A


C  H &&(( ; ;||Hh//))9((( 9***tzQ 1}}}d}}} .tT : ::(agg; ;r[   c                    |dup|du}|r|t          d          |Qt          j        j                            |          }|du rt          j        |          }nt          j        |          }t          d| g||          S )a  
    Cast array values to another data type. Can also be invoked as an array
    instance method.

    Parameters
    ----------
    arr : Array-like
    target_type : DataType or str
        Type to cast to
    safe : bool, default True
        Check for overflows or other unsafe conversions
    options : CastOptions, default None
        Additional checks pass by CastOptions
    memory_pool : MemoryPool, optional
        memory pool to use for allocations during function execution.

    Examples
    --------
    >>> 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'))
    <pyarrow.lib.TimestampArray object at ...>
    [
      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]')
    <pyarrow.lib.TimestampArray object at ...>
    [
      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'Fcast)	
ValueErrorpatypeslibensure_typer   unsafesaferE   )arrtarget_typer   r   r   safe_vars_passeds         rY   r   r   X  s    l D(Fk.E ;W0 : ; ; 	; hl..{;;5==!(55GG!&{33G#===r[   r   c                v   |2||                      |||z
            } n.|                      |          } n||                      d|          } t          |t          j                  st          j        || j                  }n=| j        |j        k    r-t          j        |                                | j                  }t          |          }t          d| g||          }|T|                                dk    r<t          j        |                                |z   t          j	                              }|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")
    <pyarrow.Int64Scalar: 1>
    >>> pc.index(arr, "ipsum", start=2)
    <pyarrow.Int64Scalar: 5>
    >>> pc.index(arr, "amet")
    <pyarrow.Int64Scalar: -1>
    Nr   r{   valueindex)
slicer   r   Scalarscalarr{   as_pyr   rE   int64)datar   startendr   r   results          rY   r   r     s   > ?::eS5[11DD::e$$DD	zz!S!!eRY'' 9	%di000	ej	 	 	%++--di888'''G7TFG[AAFV\\^^q006<<>>E1

CCCMr[   T)boundscheckr   c                J    t          |          }t          d| |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)
    <pyarrow.lib.StringArray object at ...>
    [
      "a",
      null,
      "e",
      null
    ]
    )r   take)r>   rE   )r   indicesr   r   r   s        rY   r   r     s-    P k222G$';GGGr[   c                 :   t          |t          j        t          j        t          j        f          st          j        || j                  }n=| j        |j        k    r-t          j        |                                | j                  }t          d| |g          S )ae  Replace 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)
    <pyarrow.lib.Int8Array object at ...>
    [
      1,
      2,
      5,
      3
    ]
    >>> arr = pa.array([1, 2, None, 4, None])
    >>> arr.fill_null(pa.array([10, 20, 30, 40, 50]))
    <pyarrow.lib.Int64Array object at ...>
    [
      1,
      2,
      30,
      4,
      50
    ]
    r   coalesce)	r   r   ArrayChunkedArrayr   r   r{   r   rE   )r   
fill_values     rY   	fill_nullr     s    f j28R_bi"HII EYz<<<

	
	'	'Yz//11DDD
fj%9:::r[   c                    |g }t          | t          j        t          j        f          r|                    d           nt          d |          }t          ||          }t          d| 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)
    <pyarrow.lib.UInt64Array object at ...>
    [
      5,
      4,
      2
    ]
    N)dummy
descendingc                 
    | dfS )Nr   r   key_names    rY   <lambda>z top_k_unstable.<locals>.<lambda>`  s    (L)A r[   select_k_unstabler   r   r   r   rv   mapr4   rE   r   k	sort_keysr   r   s        rY   top_k_unstabler   6  s}    J 	&28R_566 N01111AA9MM	Q	**G,vhMMMr[   c                    |g }t          | t          j        t          j        f          r|                    d           nt          d |          }t          ||          }t          d| 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)
    <pyarrow.lib.UInt64Array object at ...>
    [
      0,
      1,
      2
    ]
    N)r   	ascendingc                 
    | dfS )Nr  r   r   s    rY   r   z#bottom_k_unstable.<locals>.<lambda>  s    (K)@ r[   r   r   r   s        rY   bottom_k_unstabler  e  s}    J 	&28R_566 M/0000@@)LL	Q	**G,vhMMMr[   system)initializerr   r   c                J    t          |          }t          dg |||           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.
    )r  random)length)r*   rE   )nr  r   r   s       rY   r  r    s-    , 444G2wAFFFFr[   c                     t          |           }|dk    rt          | d         t          t          f          rt	          j        | d                   S t          | d         t                    rt	          j        | d                   S t          dt          | d                              t	          j        |           S )a  Reference 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")
    <pyarrow.compute.Expression a>
    >>> pc.field(1)
    <pyarrow.compute.Expression FieldPath(1)>
    >>> pc.field(("a", "b"))
    <pyarrow.compute.Expression FieldRef.Nested(FieldRef.Name(a) ...
    >>> pc.field("a", "b")
    <pyarrow.compute.Expression FieldRef.Nested(FieldRef.Name(a) ...
    ri   r   zCfield reference should be str, multiple str, tuple or integer, got )
r   r   strintrO   _fieldtuple_nested_fieldr   r{   )name_or_indexr
  s     rY   fieldr    s    B 	MAAvvmA&c
33 	$]1%5666a(%00 	+M!,<===9 $]1%5 6 69 9   '666r[   c                 *    t          j        |           S )a  Expression representing a scalar value.

    Creates an Expression object representing a scalar value that can be used
    in compute expressions and predicates.

    Parameters
    ----------
    value : bool, int, float or string
        Python value of the scalar. This function accepts any value that can be
        converted to a ``pyarrow.Scalar`` using ``pa.scalar()``.

    Notes
    -----
    This function differs from ``pyarrow.scalar()`` in the following way:

    * ``pyarrow.scalar()`` creates a ``pyarrow.Scalar`` object that represents
      a single value in Arrow's memory model.
    * ``pyarrow.compute.scalar()`` creates an ``Expression`` object representing
      a scalar value that can be used in compute expressions, predicates, and
      dataset filtering operations.

    Returns
    -------
    scalar_expr : Expression
        An Expression representing the scalar value
    )rO   _scalarr   s    rY   r   r     s    6 e$$$r[   )NNNN)NNrU   )lpyarrow._computer   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/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   collectionsrP   r   textwraprQ   r}   pyarrowr   rR   pyarrow.vendoredrS   rZ   r\   rd   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r   r   r[   rY   <module>r     s  $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 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 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 R R R R Rh # " " " " "             ' ' ' ' ' ' & & & & & &   :0+>> / / /P P Pf	 	 	  *  >% % %.J J J ; ; ;:     B> B> B> B>J/D / / / / /d (, )H )H )H )H )HX8; 8; 8;v,NT ,N ,N ,N ,N ,N^,N ,N ,N ,N ,N ,N^ &t G G G G G4.7 .7 .7b% % % % %r[   