arro3.compute¶
arro3.compute ¶
add ¶
add(lhs: ArrayInput, rhs: ArrayInput) -> Array
Perform lhs + rhs
, returning an error on overflow
add_wrapping ¶
add_wrapping(lhs: ArrayInput, rhs: ArrayInput) -> Array
Perform lhs + rhs
, wrapping on overflow for integer data types.
can_cast_types ¶
can_cast_types(
from_type: ArrowSchemaExportable, to_type: ArrowSchemaExportable
) -> bool
Return true if a value of type from_type
can be cast into a value of to_type
.
Parameters:
-
from_type
(ArrowSchemaExportable
) –Source type
-
to_type
(ArrowSchemaExportable
) –Destination type
Returns:
-
bool
–True if can be casted.
cast ¶
cast(input: ArrayInput, to_type: ArrowSchemaExportable) -> Array
cast(
input: ArrowStreamExportable, to_type: ArrowSchemaExportable
) -> ArrayReader
cast(
input: ArrayInput | ArrowStreamExportable, to_type: ArrowSchemaExportable
) -> Array | ArrayReader
Cast input
to the provided data type and return a new Array with type to_type
, if possible.
If input
is an Array, an Array
will be returned. If input
is a ChunkedArray
or ArrayReader
, an ArrayReader
will be returned.
Parameters:
-
input
(ArrayInput | ArrowStreamExportable
) –Input data to cast.
-
to_type
(ArrowSchemaExportable
) –The target data type to cast to. You may pass in a
Field
here if you wish to include Arrow extension metadata on the output array.
Returns:
-
Array | ArrayReader
–The casted Arrow data.
date_part ¶
date_part(input: ArrowArrayExportable, part: DatePart | DatePartT) -> Array
date_part(
input: ArrowStreamExportable, part: DatePart | DatePartT
) -> ArrayReader
date_part(
input: ArrowArrayExportable | ArrowStreamExportable,
part: DatePart | DatePartT,
) -> Array | ArrayReader
Given an array, return a new array with the extracted [DatePart
] as signed 32-bit
integer values.
Currently only supports temporal types
- Date32/Date64
- Time32/Time64
- Timestamp
- Interval
- Duration
Returns an int32-typed array unless input was a dictionary type, in which case returns the dictionary but with this function applied onto its values.
If array passed in is not of the above listed types (or is a dictionary array where the values array isn't of the above listed types), then this function will return an error.
Parameters:
-
array
–Argument to compute function.
Returns:
-
Array | ArrayReader
–The extracted date part.
dictionary_encode ¶
dictionary_encode(array: ArrayInput) -> Array
dictionary_encode(array: ArrowStreamExportable) -> ArrayReader
dictionary_encode(
array: ArrayInput | ArrowStreamExportable,
) -> Array | ArrayReader
Dictionary-encode array.
Return a dictionary-encoded version of the input array. This function does nothing if the input is already a dictionary array.
Note: for stream input, each output array will not necessarily have the same dictionary.
Parameters:
-
array
(ArrayInput | ArrowStreamExportable
) –Argument to compute function.
Returns:
-
Array | ArrayReader
–The dictionary-encoded array.
filter ¶
filter(values: ArrayInput, predicate: ArrayInput) -> Array
filter(
values: ArrowStreamExportable, predicate: ArrowStreamExportable
) -> ArrayReader
filter(
values: ArrayInput | ArrowStreamExportable,
predicate: ArrayInput | ArrowStreamExportable,
) -> Array | ArrayReader
Returns a filtered values
array where the corresponding elements of
predicate
are true
.
If input
is an Array, an Array
will be returned. If input
is a ChunkedArray
or ArrayReader
, an ArrayReader
will be returned.
is_not_null ¶
is_not_null(input: ArrayInput) -> Array
is_not_null(input: ArrowStreamExportable) -> ArrayReader
is_not_null(input: ArrayInput | ArrowStreamExportable) -> Array | ArrayReader
Returns a non-null boolean-typed array with whether each value of the array is not null.
If input
is an Array, an Array
will be returned. If input
is a ChunkedArray
or ArrayReader
, an ArrayReader
will be returned.
Parameters:
-
input
(ArrayInput | ArrowStreamExportable
) –Input data
Returns:
-
Array | ArrayReader
–Output
is_null ¶
is_null(input: ArrayInput) -> Array
is_null(input: ArrowStreamExportable) -> ArrayReader
is_null(input: ArrayInput | ArrowStreamExportable) -> Array | ArrayReader
Returns a non-null boolean-typed array with whether each value of the array is null.
If input
is an Array, an Array
will be returned. If input
is a ChunkedArray
or ArrayReader
, an ArrayReader
will be returned.
Parameters:
-
input
(ArrayInput | ArrowStreamExportable
) –Input data
Returns:
-
Array | ArrayReader
–Output
max ¶
max(input: ArrayInput | ArrowStreamExportable) -> Scalar
Returns the max of values in the array.
min ¶
min(input: ArrayInput | ArrowStreamExportable) -> Scalar
Returns the min of values in the array.
mul ¶
mul(lhs: ArrayInput, rhs: ArrayInput) -> Array
Perform lhs * rhs
, returning an error on overflow
mul_wrapping ¶
mul_wrapping(lhs: ArrayInput, rhs: ArrayInput) -> Array
Perform lhs * rhs
, wrapping on overflow for integer data types.
neg_wrapping ¶
neg_wrapping(array: ArrayInput) -> Array
Negates each element of array, wrapping on overflow for integer data types.
sub ¶
sub(lhs: ArrayInput, rhs: ArrayInput) -> Array
Perform lhs - rhs
, returning an error on overflow
sub_wrapping ¶
sub_wrapping(lhs: ArrayInput, rhs: ArrayInput) -> Array
Perform lhs - rhs
, wrapping on overflow for integer data types.
sum ¶
sum(input: ArrayInput | ArrowStreamExportable) -> Scalar
Returns the sum of values in the array.
take ¶
take(values: ArrayInput, indices: ArrayInput) -> Array
Take elements by index from Array, creating a new Array from those indexes.
┌─────────────────┐ ┌─────────┐ ┌─────────────────┐
│ A │ │ 0 │ │ A │
├─────────────────┤ ├─────────┤ ├─────────────────┤
│ D │ │ 2 │ │ B │
├─────────────────┤ ├─────────┤ take(values, indices) ├─────────────────┤
│ B │ │ 3 │ ─────────────────────────▶ │ C │
├─────────────────┤ ├─────────┤ ├─────────────────┤
│ C │ │ 1 │ │ D │
├─────────────────┤ └─────────┘ └─────────────────┘
│ E │
└─────────────────┘
values array indices array result
Parameters:
-
values
(ArrayInput
) –The input Arrow data to select from.
-
indices
(ArrayInput
) –The indices within
values
to take. This must be a numeric array.
Returns:
-
Array
–The selected arrow data.