arkouda.numpy

Submodules

Attributes

Exceptions

NonUniqueError

Exception raised when duplicate values are found in a set of keys that are expected to be unique.

RegistrationError

Error/Exception used when the Arkouda Server cannot register an object.

Classes

ARKOUDA_SUPPORTED_DTYPES

Built-in immutable sequence.

ARKOUDA_SUPPORTED_INTS

Built-in immutable sequence.

BoolDType

DType class corresponding to the scalar type and dtype of the same name.

ByteDType

DType class corresponding to the scalar type and dtype of the same name.

BytesDType

DType class corresponding to the scalar type and dtype of the same name.

CLongDoubleDType

DType class corresponding to the scalar type and dtype of the same name.

Complex128DType

DType class corresponding to the scalar type and dtype of the same name.

Complex64DType

DType class corresponding to the scalar type and dtype of the same name.

DType

DTypeObjects

Build an immutable unordered collection of unique elements.

DTypes

Build an immutable unordered collection of unique elements.

DateTime64DType

DType class corresponding to the scalar type and dtype of the same name.

Datetime

Represents a date and/or time.

ErrorMode

Create a collection of name/value pairs.

False_

Boolean type (True or False), stored as a byte.

Float16DType

DType class corresponding to the scalar type and dtype of the same name.

Float32DType

DType class corresponding to the scalar type and dtype of the same name.

Float64DType

DType class corresponding to the scalar type and dtype of the same name.

Int16DType

DType class corresponding to the scalar type and dtype of the same name.

Int32DType

DType class corresponding to the scalar type and dtype of the same name.

Int64DType

DType class corresponding to the scalar type and dtype of the same name.

Int8DType

DType class corresponding to the scalar type and dtype of the same name.

IntDType

DType class corresponding to the scalar type and dtype of the same name.

LongDType

DType class corresponding to the scalar type and dtype of the same name.

LongDoubleDType

DType class corresponding to the scalar type and dtype of the same name.

LongLongDType

DType class corresponding to the scalar type and dtype of the same name.

NUMBER_FORMAT_STRINGS

dict() -> new empty dictionary

NumericDTypes

Build an immutable unordered collection of unique elements.

ObjectDType

DType class corresponding to the scalar type and dtype of the same name.

ScalarDTypes

Build an immutable unordered collection of unique elements.

ScalarType

Built-in immutable sequence.

SegArray

SeriesDTypes

dict() -> new empty dictionary

ShortDType

DType class corresponding to the scalar type and dtype of the same name.

StrDType

DType class corresponding to the scalar type and dtype of the same name.

Strings

Represents an array of strings whose data resides on the

TimeDelta64DType

DType class corresponding to the scalar type and dtype of the same name.

Timedelta

Represents a duration, the difference between two dates or times.

True_

Boolean type (True or False), stored as a byte.

UByteDType

DType class corresponding to the scalar type and dtype of the same name.

UInt16DType

DType class corresponding to the scalar type and dtype of the same name.

UInt32DType

DType class corresponding to the scalar type and dtype of the same name.

UInt64DType

DType class corresponding to the scalar type and dtype of the same name.

UInt8DType

DType class corresponding to the scalar type and dtype of the same name.

UIntDType

DType class corresponding to the scalar type and dtype of the same name.

ULongDType

DType class corresponding to the scalar type and dtype of the same name.

ULongLongDType

DType class corresponding to the scalar type and dtype of the same name.

UShortDType

DType class corresponding to the scalar type and dtype of the same name.

VoidDType

DType class corresponding to the scalar type and dtype of the same name.

all_scalars

Mixin to prevent iteration, without being compatible with Iterable.

bigint

Dtype sentinel for Arkouda's variable-width (arbitrary-precision) integers.

bigint_

Scalar type for Arkouda's variable-width integer dtype.

bitType

Unsigned signed integer type, 64bit on 64bit systems and 32bit on 32bit

bool

Boolean type (True or False), stored as a byte.

bool_scalars

Mixin to prevent iteration, without being compatible with Iterable.

byte

Signed integer type, compatible with C char.

bytes_

A byte string.

cdouble

Complex number type composed of two double-precision floating-point

clongdouble

Complex number type composed of two extended-precision floating-point

complex128

Complex number type composed of two double-precision floating-point

complex64

Complex number type composed of two single-precision floating-point

csingle

Complex number type composed of two single-precision floating-point

datetime64

If created from a 64-bit integer, it represents an offset from

double

Double-precision floating-point number type, compatible with Python

finfo

finfo(dtype)

flexible

Abstract base class of all scalar types without predefined length.

float16

Half-precision floating-point number type.

float32

Single-precision floating-point number type, compatible with C float.

float64

Double-precision floating-point number type, compatible with Python

float_scalars

Mixin to prevent iteration, without being compatible with Iterable.

floating

Abstract base class of all floating-point scalar types.

half

Half-precision floating-point number type.

iinfo

iinfo(type)

inexact

Abstract base class of all numeric scalar types with a (potentially)

int16

Signed integer type, compatible with C short.

int32

Signed integer type, compatible with C int.

int64

Default signed integer type, 64bit on 64bit systems and 32bit on 32bit

int8

Signed integer type, compatible with C char.

intTypes

Build an immutable unordered collection of unique elements.

int_scalars

Mixin to prevent iteration, without being compatible with Iterable.

intc

Signed integer type, compatible with C int.

intp

Default signed integer type, 64bit on 64bit systems and 32bit on 32bit

longdouble

Extended-precision floating-point number type, compatible with C

longlong

Signed integer type, compatible with C long long.

number

Abstract base class of all numeric scalar types.

numeric_and_bool_scalars

Mixin to prevent iteration, without being compatible with Iterable.

numeric_scalars

Mixin to prevent iteration, without being compatible with Iterable.

numpy_scalars

Mixin to prevent iteration, without being compatible with Iterable.

pdarray

The basic arkouda array class. This class contains only the

sctypeDict

dict() -> new empty dictionary

short

Signed integer type, compatible with C short.

signedinteger

Abstract base class of all signed integer scalar types.

single

Single-precision floating-point number type, compatible with C float.

str_

A unicode string.

str_scalars

Mixin to prevent iteration, without being compatible with Iterable.

timedelta64

A timedelta stored as a 64-bit integer.

ubyte

Unsigned integer type, compatible with C unsigned char.

uint

Unsigned signed integer type, 64bit on 64bit systems and 32bit on 32bit

uint16

Unsigned integer type, compatible with C unsigned short.

uint32

Unsigned integer type, compatible with C unsigned int.

uint64

Unsigned signed integer type, 64bit on 64bit systems and 32bit on 32bit

uint8

Unsigned integer type, compatible with C unsigned char.

uintc

Unsigned integer type, compatible with C unsigned int.

uintp

Unsigned signed integer type, 64bit on 64bit systems and 32bit on 32bit

ulonglong

Signed integer type, compatible with C unsigned long long.

unsignedinteger

Abstract base class of all unsigned integer scalar types.

ushort

Unsigned integer type, compatible with C unsigned short.

void

np.void(length_or_data, /, dtype=None)

Functions

abs(→ arkouda.numpy.pdarrayclass.pdarray)

Return the element-wise absolute value of the array.

align(*args)

Map multiple arrays of sparse identifiers to a common 0-up index.

allclose(→ bool)

Returns True if all elements of a and b are equal within a tolerance.

append(→ arkouda.numpy.pdarrayclass.pdarray)

Append values to the end of an array.

arange(…)

Create a pdarray of consecutive integers within the interval [start, stop).

arccos(→ arkouda.numpy.pdarrayclass.pdarray)

Return the element-wise inverse cosine of the array. The result is between 0 and pi.

arccosh(→ arkouda.numpy.pdarrayclass.pdarray)

Return the element-wise inverse hyperbolic cosine of the array.

arcsin(→ arkouda.numpy.pdarrayclass.pdarray)

Return the element-wise inverse sine of the array. The result is between -pi/2 and pi/2.

arcsinh(→ arkouda.numpy.pdarrayclass.pdarray)

Return the element-wise inverse hyperbolic sine of the array.

arctan(→ arkouda.numpy.pdarrayclass.pdarray)

Return the element-wise inverse tangent of the array. The result is between -pi/2 and pi/2.

arctan2(→ arkouda.numpy.pdarrayclass.pdarray)

Return the element-wise inverse tangent of the array pair. The result chosen is the

arctanh(→ arkouda.numpy.pdarrayclass.pdarray)

Return the element-wise inverse hyperbolic tangent of the array.

argmaxk(→ pdarray)

Find the indices corresponding to the k maximum values of an array.

argmink(→ pdarray)

Finds the indices corresponding to the k minimum values of an array.

argsort(→ arkouda.numpy.pdarrayclass.pdarray)

Return the permutation (indices) that sorts the array.

array(…)

Convert a Python, NumPy, or Arkouda array-like into a pdarray or Strings object,

array_equal(→ bool)

Compares two pdarrays for equality.

attach(name)

Attach a previously created Arkouda object by its registered name.

attach_all(names)

Attach to all objects registered with the provided names.

base_repr(number[, base, padding])

Return a string representation of a number in the given base system.

bigint_from_uint_arrays(arrays[, max_bits])

Create a bigint pdarray from an iterable of uint pdarrays.

binary_repr(num[, width])

Return the binary representation of the input number as a string.

broadcast_arrays(...)

Broadcast arrays to a common shape.

broadcast_dims(→ Tuple[int, Ellipsis])

Determine the broadcasted shape of two arrays given their shapes.

broadcast_shapes(→ Tuple[int, Ellipsis])

Determine a broadcasted shape, given an arbitary number of shapes.

broadcast_to(→ arkouda.numpy.pdarrayclass.pdarray)

Broadcast the array to the specified shape.

can_cast(→ bool)

Determine whether a value of one dtype can be safely cast to another,

cast(…)

Cast an array to another dtype.

ceil(→ arkouda.numpy.pdarrayclass.pdarray)

Return the element-wise ceiling of the array.

clear(→ None)

Send a clear message to clear all unregistered data from the server symbol table.

clip(→ arkouda.numpy.pdarrayclass.pdarray)

Clip (limit) the values in an array to a given range [lo,hi].

clz(→ pdarray)

Count leading zeros for each integer in an array.

coargsort(→ arkouda.numpy.pdarrayclass.pdarray)

Return the permutation that groups the rows (left-to-right), if the

concatenate(...)

Concatenate a list or tuple of pdarray or Strings objects into

copy(→ Union[arkouda.numpy.strings.Strings, ...)

Return a deep copy of the given Arkouda object.

corr(→ numpy.float64)

Return the correlation between x and y.

cos(→ arkouda.numpy.pdarrayclass.pdarray)

Return the element-wise cosine of the array.

cosh(→ arkouda.numpy.pdarrayclass.pdarray)

Return the element-wise hyperbolic cosine of the array.

count_nonzero(→ arkouda.numpy.dtypes.int_scalars)

Compute the nonzero count of a given array. 1D case only, for now.

cov(→ numpy.float64)

Return the covariance of x and y.

ctz(→ pdarray)

Count trailing zeros for each integer in an array.

cumprod(→ arkouda.numpy.pdarrayclass.pdarray)

Return the cumulative product over the array.

cumsum(→ arkouda.numpy.pdarrayclass.pdarray)

Return the cumulative sum over the array.

date_range([start, end, periods, freq, tz, normalize, ...])

Create a fixed frequency Datetime range. Alias for

deg2rad(→ arkouda.numpy.pdarrayclass.pdarray)

Converts angles element-wise from degrees to radians.

delete(→ arkouda.numpy.pdarrayclass.pdarray)

Return a copy of 'arr' with elements along the specified axis removed.

diff(→ pdarray)

Calculate the n-th discrete difference along the given axis.

divmod(→ Tuple[pdarray, pdarray])

dot(→ Union[arkouda.numpy.dtypes.numeric_scalars, ...)

Computes dot product of two arrays.

dtype(x)

Normalize a dtype-like input into an Arkouda dtype sentinel or a NumPy dtype.

errstate(→ Iterator[None])

Context manager to temporarily set floating-point error handling.

exp(→ arkouda.numpy.pdarrayclass.pdarray)

Return the element-wise exponential of the array.

expm1(→ arkouda.numpy.pdarrayclass.pdarray)

Return the element-wise exponential of the array minus one.

eye(→ arkouda.numpy.pdarrayclass.pdarray)

Return a pdarray with zeros everywhere except along a diagonal, which is all ones.

fabs(→ arkouda.numpy.pdarrayclass.pdarray)

Compute the absolute values element-wise, casting to a float beforehand.

find(query, space[, all_occurrences, remove_missing])

Return indices of query items in a search list of items.

flip(…)

Reverse an array's values along a particular axis or axes.

floor(→ arkouda.numpy.pdarrayclass.pdarray)

Return the element-wise floor of the array.

fmod(→ pdarray)

Returns the element-wise remainder of division.

format_float_positional(x[, precision, unique, ...])

Format a floating-point scalar as a decimal string in positional notation.

format_float_scientific(x[, precision, unique, trim, ...])

Format a floating-point scalar as a decimal string in scientific notation.

full(→ Union[arkouda.numpy.pdarrayclass.pdarray, ...)

Create a pdarray filled with fill_value.

full_like(→ Union[arkouda.numpy.pdarrayclass.pdarray, ...)

Create a pdarray filled with fill_value of the same size and dtype as an existing

get_byteorder(→ str)

Get a concrete byteorder (turns '=' into '<' or '>') on the client.

get_server_byteorder(→ str)

Get the server's byteorder.

geterr(→ Dict[str, _ErrorMode])

Get the current Arkouda floating-point error handling settings.

geterrcall(→ Optional[Callable[[str, str], None]])

Get the current callable used when error mode is 'call'.

hash(…)

Return an element-wise hash of the array or list of arrays.

histogram(→ Tuple[arkouda.numpy.pdarrayclass.pdarray, ...)

Compute a histogram of evenly spaced bins over the range of an array.

histogram2d(...)

Compute the bi-dimensional histogram of two data samples with evenly spaced bins.

histogramdd(...)

Compute the multidimensional histogram of data in sample with evenly spaced bins.

hstack(→ arkouda.numpy.pdarrayclass.pdarray)

Stack arrays in sequence horizontally (column wise).

in1d(→ arkouda.pandas.groupbyclass.groupable)

Test whether each element of a 1-D array is also present in a second array.

in1d_intervals(vals, intervals[, symmetric])

Test each value for membership in any of a set of half-open (pythonic) intervals.

indexof1d(→ arkouda.numpy.pdarrayclass.pdarray)

Return indices of query items in a search list of items. Items not found will be excluded.

intersect1d(...)

Find the intersection of two arrays.

interval_lookup(keys, values, arguments[, fillvalue, ...])

Apply a function defined over intervals to an array of arguments.

isSupportedBool(num)

Deprecated alias for is_supported_bool().

isSupportedDType(num)

Deprecated alias for is_supported_dtype().

isSupportedFloat(num)

Deprecated alias for is_supported_float().

isSupportedInt(num)

Deprecated alias for is_supported_int().

isSupportedNumber(num)

Deprecated alias for is_supported_number().

is_cosorted(arrays)

Return True iff the arrays are cosorted.

is_registered(→ bool)

Determine if the provided name is associated with a registered Arkouda object.

is_supported_bool(→ TypeGuard[bool_scalars])

Whether a scalar is an arkouda supported boolean dtype.

is_supported_dtype(→ bool)

Whether a scalar is an arkouda supported dtype.

is_supported_float(→ TypeGuard[float_scalars])

Whether a scalar is an arkouda supported float dtype.

is_supported_int(→ TypeGuard[int_scalars])

Whether a scalar is an arkouda supported integer dtype.

is_supported_number(→ TypeGuard[numeric_scalars])

Whether a scalar is an arkouda supported numeric dtype.

isfinite(→ arkouda.numpy.pdarrayclass.pdarray)

Return the element-wise isfinite check applied to the array.

isinf(→ arkouda.numpy.pdarrayclass.pdarray)

Return the element-wise isinf check applied to the array.

isnan(→ arkouda.numpy.pdarrayclass.pdarray)

Return the element-wise isnan check applied to the array.

isnumeric(→ arkouda.numpy.pdarrayclass.pdarray)

Return a boolean pdarray where index i indicates whether string i of the

isscalar(element)

Returns True if the type of element is a scalar type.

issubdtype(arg1, arg2)

Returns True if first argument is a typecode lower/equal in type hierarchy.

left_align(left, right)

Map two arrays of sparse identifiers to the 0-up index.

linspace(→ arkouda.numpy.pdarrayclass.pdarray)

Return evenly spaced numbers over a specified interval.

log(→ arkouda.numpy.pdarrayclass.pdarray)

Return the element-wise natural log of the array.

log10(→ arkouda.numpy.pdarrayclass.pdarray)

Return the element-wise base 10 log of the array.

log1p(→ arkouda.numpy.pdarrayclass.pdarray)

Return the element-wise natural log of one plus the array.

log2(→ arkouda.numpy.pdarrayclass.pdarray)

Return the element-wise base 2 log of the array.

logical_not(…)

Compute the truth value of NOT x element-wise.

logspace(→ arkouda.numpy.pdarrayclass.pdarray)

Create a pdarray of numbers evenly spaced on a log scale.

lookup(keys, values, arguments[, fillvalue])

Apply the function defined by the mapping keys --> values to arguments.

matmul(→ arkouda.numpy.pdarrayclass.pdarray)

Compute the product of two matrices.

maximum(→ arkouda.numpy.pdarrayclass.pdarray)

Return the element-wise maximum of x1 and x2. Where either is a nan, return nan,

maxk(→ pdarray)

Find the k maximum values of an array.

may_share_memory(a, b)

Conservative version akin to numpy.may_share_memory.

median(→ numpy.float64)

Compute the median of a given array. 1d case only, for now.

minimum(→ arkouda.numpy.pdarrayclass.pdarray)

Return the element-wise minimum of x1 and x2. Where either is a nan, return nan,

mink(→ pdarray)

Find the k minimum values of an array.

mod(→ pdarray)

Returns the element-wise remainder of division.

nextafter(→ Union[arkouda.numpy.pdarrayclass.pdarray, ...)

Return the next floating-point value after x1 towards x2, element-wise.

ones(→ arkouda.numpy.pdarrayclass.pdarray)

Create a pdarray filled with ones.

ones_like(→ arkouda.numpy.pdarrayclass.pdarray)

Create a one-filled pdarray of the same size and dtype as an existing

parity(→ pdarray)

Find the bit parity (XOR of all bits) for each integer in an array.

percentile(...)

Compute the q-th percentile of the data along the specified axis.

popcount(→ pdarray)

Find the population (number of bits set) for each integer in an array.

power(→ pdarray)

Raises an array to a power. If where is given, the operation will only take place in the positions

promote_to_common_dtype(→ Tuple[Any, ...)

Promote a list of pdarrays to a common dtype.

putmask(→ None)

Overwrite elements of A with elements from B based upon a mask array.

quantile(→ Union[arkouda.numpy.dtypes.numeric_scalars, ...)

Compute the q-th quantile of the data along the specified axis.

rad2deg(→ arkouda.numpy.pdarrayclass.pdarray)

Converts angles element-wise from radians to degrees.

randint(→ arkouda.numpy.pdarrayclass.pdarray)

Generate a pdarray of randomized int, float, or bool values in a

random_strings_lognormal(→ arkouda.numpy.strings.Strings)

Generate random strings with log-normally distributed lengths and

random_strings_uniform(→ arkouda.numpy.strings.Strings)

Generate random strings with lengths uniformly distributed between

register_all(data)

Register all objects in the provided dictionary.

repeat(→ arkouda.numpy.pdarrayclass.pdarray)

Repeat each element of an array after themselves.

resolve_scalar_dtype(→ str)

Try to infer what dtype arkouda_server should treat val as.

result_type(*args)

Determine the result dtype from one or more inputs, following NumPy’s

right_align(left, right)

Map two arrays of sparse values to the 0-up index.

rotl(→ pdarray)

Rotate bits of <x> to the left by <rot>.

rotr(→ pdarray)

Rotate bits of <x> to the left by <rot>.

round(→ arkouda.numpy.pdarrayclass.pdarray)

Return the element-wise rounding of the array.

scalar_array(→ arkouda.numpy.pdarrayclass.pdarray)

Create a pdarray from a single scalar value.

search_intervals(vals, intervals[, tiebreak, hierarchical])

Return the index of the best interval containing each query value.

searchsorted(→ Union[int, ...)

Find indices where elements should be inserted to maintain order.

setdiff1d(→ Union[arkouda.numpy.pdarrayclass.pdarray, ...)

Find the set difference of two arrays.

seterr(→ Dict[str, _ErrorMode])

Set how Arkouda handles floating-point errors.

seterrcall(→ Optional[Callable[[str, str], None]])

Set the callable invoked when an error category is set to 'call'.

setxor1d(→ Union[arkouda.numpy.pdarrayclass.pdarray, ...)

Find the set exclusive-or (symmetric difference) of two arrays.

shape(→ Tuple)

Return the shape of an array.

shares_memory(a, b)

Return True if a and b share any Arkouda server-side buffers.

sign(→ arkouda.numpy.pdarrayclass.pdarray)

Return the element-wise sign of the array.

sin(→ arkouda.numpy.pdarrayclass.pdarray)

Return the element-wise sine of the array.

sinh(→ arkouda.numpy.pdarrayclass.pdarray)

Return the element-wise hyperbolic sine of the array.

sort(→ arkouda.numpy.pdarrayclass.pdarray)

Return a sorted copy of the array. Only sorts numeric arrays;

sqrt(→ pdarray)

Takes the square root of array. If where is given, the operation will only take place in

square(→ arkouda.numpy.pdarrayclass.pdarray)

Return the element-wise square of the array.

squeeze(→ arkouda.numpy.pdarrayclass.pdarray)

Remove degenerate (size one) dimensions from an array.

standard_normal(→ arkouda.numpy.pdarrayclass.pdarray)

Draw real numbers from the standard normal distribution.

take(→ arkouda.numpy.pdarrayclass.pdarray)

Take elements from an array along an axis.

tan(→ arkouda.numpy.pdarrayclass.pdarray)

Return the element-wise tangent of the array.

tanh(→ arkouda.numpy.pdarrayclass.pdarray)

Return the element-wise hyperbolic tangent of the array.

tile(→ arkouda.numpy.pdarrayclass.pdarray)

Construct an array by repeating A the number of times given by reps.

timedelta_range([start, end, periods, freq, name, closed])

Return a fixed frequency TimedeltaIndex, with day as the default

transpose(→ arkouda.numpy.pdarrayclass.pdarray)

Compute the transpose of a matrix.

tril(→ arkouda.numpy.pdarrayclass.pdarray)

Return a copy of the pda with the upper triangle zeroed out.

triu(→ arkouda.numpy.pdarrayclass.pdarray)

Return a copy of the pda with the lower triangle zeroed out.

trunc(→ arkouda.numpy.pdarrayclass.pdarray)

Return the element-wise truncation of the array.

typename(char)

Return a description for the given data type code.

uniform(, high, seed, ...)

Generate a pdarray with uniformly distributed random float values

union1d(→ arkouda.pandas.groupbyclass.groupable)

Find the union of two arrays/List of Arrays.

unregister(→ str)

Unregister an Arkouda object by its name.

unregister_all(names)

Unregister all Arkouda objects associated with the provided names.

unsqueeze(p)

Ensure that the input is returned as a list.

value_counts(→ tuple[arkouda.groupbyclass.groupable, ...)

Count the occurrences of the unique values of an array.

vecdot(→ Union[arkouda.numpy.dtypes.numeric_scalars, ...)

Computes the numpy-style vecdot product of two matrices. This differs from the

vstack(→ arkouda.numpy.pdarrayclass.pdarray)

Stack arrays in sequence vertically (row wise).

where(→ Union[arkouda.numpy.pdarrayclass.pdarray, ...)

Return an array with elements chosen from A and B based upon a

zero_up(vals)

Map an array of sparse values to 0-up indices.

zeros(→ arkouda.numpy.pdarrayclass.pdarray)

Create a pdarray filled with zeros.

zeros_like(→ arkouda.numpy.pdarrayclass.pdarray)

Create a zero-filled pdarray of the same size and dtype as an existing

Package Contents

class arkouda.numpy.ARKOUDA_SUPPORTED_DTYPES

Built-in immutable sequence.

If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.

If the argument is a tuple, the return value is the same object.

count(value, /)

Return number of occurrences of value.

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

class arkouda.numpy.ARKOUDA_SUPPORTED_INTS

Built-in immutable sequence.

If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.

If the argument is a tuple, the return value is the same object.

count(value, /)

Return number of occurrences of value.

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

class arkouda.numpy.BoolDType

Bases: numpy.dtype

DType class corresponding to the scalar type and dtype of the same name.

Please see numpy.dtype for the typical way to create dtype instances and arrays.dtypes for additional information.

class arkouda.numpy.ByteDType

Bases: numpy.dtypes._IntegerAbstractDType

DType class corresponding to the scalar type and dtype of the same name.

Please see numpy.dtype for the typical way to create dtype instances and arrays.dtypes for additional information.

class arkouda.numpy.BytesDType

Bases: numpy.dtype

DType class corresponding to the scalar type and dtype of the same name.

Please see numpy.dtype for the typical way to create dtype instances and arrays.dtypes for additional information.

class arkouda.numpy.CLongDoubleDType

Bases: numpy.dtypes._ComplexAbstractDType

DType class corresponding to the scalar type and dtype of the same name.

Please see numpy.dtype for the typical way to create dtype instances and arrays.dtypes for additional information.

class arkouda.numpy.Complex128DType

Bases: numpy.dtypes._ComplexAbstractDType

DType class corresponding to the scalar type and dtype of the same name.

Please see numpy.dtype for the typical way to create dtype instances and arrays.dtypes for additional information.

class arkouda.numpy.Complex64DType

Bases: numpy.dtypes._ComplexAbstractDType

DType class corresponding to the scalar type and dtype of the same name.

Please see numpy.dtype for the typical way to create dtype instances and arrays.dtypes for additional information.

class arkouda.numpy.DType[source]
BIGINT(*args, **kwargs)
BOOL(*args, **kwargs)
COMPLEX128(*args, **kwargs)
COMPLEX64(*args, **kwargs)
FLOAT(*args, **kwargs)
FLOAT32(*args, **kwargs)
FLOAT64(*args, **kwargs)
INT(*args, **kwargs)
INT16(*args, **kwargs)
INT32(*args, **kwargs)
INT64(*args, **kwargs)
INT8(*args, **kwargs)
STR(*args, **kwargs)
UINT(*args, **kwargs)
UINT16(*args, **kwargs)
UINT32(*args, **kwargs)
UINT64(*args, **kwargs)
UINT8(*args, **kwargs)
name(*args, **kwargs)

The name of the Enum member.

value(*args, **kwargs)

The value of the Enum member.

class arkouda.numpy.DTypeObjects

Build an immutable unordered collection of unique elements.

copy()

Return a shallow copy of a set.

difference(*others)

Return a new set with elements in the set that are not in the others.

intersection(*others)

Return a new set with elements common to the set and all others.

isdisjoint(other, /)

Return True if two sets have a null intersection.

issubset(other, /)

Report whether another set contains this set.

issuperset(other, /)

Report whether this set contains another set.

symmetric_difference(other, /)

Return a new set with elements in either the set or other but not both.

union(*others)

Return a new set with elements from the set and all others.

class arkouda.numpy.DTypes

Build an immutable unordered collection of unique elements.

copy()

Return a shallow copy of a set.

difference(*others)

Return a new set with elements in the set that are not in the others.

intersection(*others)

Return a new set with elements common to the set and all others.

isdisjoint(other, /)

Return True if two sets have a null intersection.

issubset(other, /)

Report whether another set contains this set.

issuperset(other, /)

Report whether this set contains another set.

symmetric_difference(other, /)

Return a new set with elements in either the set or other but not both.

union(*others)

Return a new set with elements from the set and all others.

class arkouda.numpy.DateTime64DType

Bases: numpy.dtype

DType class corresponding to the scalar type and dtype of the same name.

Please see numpy.dtype for the typical way to create dtype instances and arrays.dtypes for additional information.

class arkouda.numpy.Datetime(pda, unit: str = _BASE_UNIT)[source]

Bases: _AbstractBaseTime

Represents a date and/or time.

Datetime is the Arkouda analog to pandas DatetimeIndex and other timeseries data types.

Parameters:
  • pda (int64 pdarray, pd.DatetimeIndex, pd.Series, or np.datetime64 array)

  • unit (str, default 'ns') –

    For int64 pdarray, denotes the unit of the input. Ignored for pandas and numpy arrays, which carry their own unit. Not case-sensitive; prefixes of full names (like ‘sec’) are accepted.

    Possible values:

    • ’weeks’ or ‘w’

    • ’days’ or ‘d’

    • ’hours’ or ‘h’

    • ’minutes’, ‘m’, or ‘t’

    • ’seconds’ or ‘s’

    • ’milliseconds’, ‘ms’, or ‘l’

    • ’microseconds’, ‘us’, or ‘u’

    • ’nanoseconds’, ‘ns’, or ‘n’

    Unlike in pandas, units cannot be combined or mixed with integers

Notes

The .values attribute is always in nanoseconds with int64 dtype.

property date
property day
property day_of_week
property day_of_year
property dayofweek
property dayofyear
property hour
property is_leap_year
is_registered() numpy.bool_[source]

Return True iff the object is contained in the registry or is a component of a registered object.

Returns:

Indicates if the object is contained in the registry

Return type:

numpy.bool

Raises:

RegistrationError – Raised if there’s a server-side error or a mis-match of registered components

Notes

Objects registered with the server are immune to deletion until they are unregistered.

isocalendar()[source]
property microsecond
property millisecond
property minute
property month
property nanosecond
register(user_defined_name)[source]

Register this Datetime object and underlying components with the Arkouda server.

Parameters:

user_defined_name (str) – user defined name the Datetime is to be registered under, this will be the root name for underlying components

Returns:

The same Datetime which is now registered with the arkouda server and has an updated name. This is an in-place modification, the original is returned to support a fluid programming style. Please note you cannot register two different Datetimes with the same name.

Return type:

Datetime

Raises:
  • TypeError – Raised if user_defined_name is not a str

  • RegistrationError – If the server was unable to register the Datetimes with the user_defined_name

Notes

Objects registered with the server are immune to deletion until they are unregistered.

property second
special_objType = 'Datetime'
sum()[source]

Return sum of array elements along the given axis.

Parameters:
  • axis (int, Tuple[int, ...], optional, default = None) – The axis or axes along which to do the operation If None, the computation is done across the entire array.

  • keepdims (bool, optional, default = False) – Whether to keep the singleton dimension(s) along axis in the result.

Returns:

numeric_scalars if axis is omitted, in which case operation is done over entire array pdarray if axis is supplied, in which case the operation is done along that axis

Return type:

numeric_scalars or pdarray

Raises:
  • TypeError – Raised if pda is not a pdarray instance

  • RuntimeError – Raised if there’s a server-side error thrown

Examples

>>> import arkouda as ak
>>> ak.sum(ak.array([1,2,3,4,5]))
np.int64(15)
>>> ak.sum(ak.array([5.5,4.5,3.5,2.5,1.5]))
np.float64(17.5)
>>> ak.array([[1,2,3],[5,4,3]]).sum(axis=1)
array([6 12])

Notes

Works as a method of a pdarray (e.g. a.sum()) or a standalone function (e.g. ak.sum(a))

supported_opeq
supported_with_datetime
supported_with_pdarray
supported_with_r_datetime
supported_with_r_pdarray
supported_with_r_timedelta
supported_with_timedelta
to_pandas()[source]

Convert array to a pandas DatetimeIndex. Note: if the array size exceeds client.maxTransferBytes, a RuntimeError is raised.

See also

to_ndarray

unregister()[source]

Unregister this Datetime object in the arkouda server which was previously registered using register() and/or attached to using attach().

Raises:

RegistrationError – If the object is already unregistered or if there is a server error when attempting to unregister

Notes

Objects registered with the server are immune to deletion until they are unregistered.

property week
property weekday
property weekofyear
property year
class arkouda.numpy.ErrorMode(*args, **kwds)[source]

Bases: enum.Enum

Create a collection of name/value pairs.

Example enumeration:

>>> class Color(Enum):
...     RED = 1
...     BLUE = 2
...     GREEN = 3

Access them by:

  • attribute access:

    >>> Color.RED
    <Color.RED: 1>
    
  • value lookup:

    >>> Color(1)
    <Color.RED: 1>
    
  • name lookup:

    >>> Color['RED']
    <Color.RED: 1>
    

Enumerations can be iterated over, and know how many members they have:

>>> len(Color)
3
>>> list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.

ignore = 'ignore'
return_validity = 'return_validity'
strict = 'strict'
class arkouda.numpy.False_

Bases: numpy.generic

Boolean type (True or False), stored as a byte.

Warning

The bool type is not a subclass of the int_ type (the bool is not even a number type). This is different than Python’s default implementation of bool as a sub-class of int.

Character code:

'?'

class arkouda.numpy.Float16DType

Bases: numpy.dtypes._FloatAbstractDType

DType class corresponding to the scalar type and dtype of the same name.

Please see numpy.dtype for the typical way to create dtype instances and arrays.dtypes for additional information.

class arkouda.numpy.Float32DType

Bases: numpy.dtypes._FloatAbstractDType

DType class corresponding to the scalar type and dtype of the same name.

Please see numpy.dtype for the typical way to create dtype instances and arrays.dtypes for additional information.

class arkouda.numpy.Float64DType

Bases: numpy.dtypes._FloatAbstractDType

DType class corresponding to the scalar type and dtype of the same name.

Please see numpy.dtype for the typical way to create dtype instances and arrays.dtypes for additional information.

class arkouda.numpy.Int16DType

Bases: numpy.dtypes._IntegerAbstractDType

DType class corresponding to the scalar type and dtype of the same name.

Please see numpy.dtype for the typical way to create dtype instances and arrays.dtypes for additional information.

class arkouda.numpy.Int32DType

Bases: numpy.dtypes._IntegerAbstractDType

DType class corresponding to the scalar type and dtype of the same name.

Please see numpy.dtype for the typical way to create dtype instances and arrays.dtypes for additional information.

class arkouda.numpy.Int64DType

Bases: numpy.dtypes._IntegerAbstractDType

DType class corresponding to the scalar type and dtype of the same name.

Please see numpy.dtype for the typical way to create dtype instances and arrays.dtypes for additional information.

class arkouda.numpy.Int8DType

Bases: numpy.dtypes._IntegerAbstractDType

DType class corresponding to the scalar type and dtype of the same name.

Please see numpy.dtype for the typical way to create dtype instances and arrays.dtypes for additional information.

class arkouda.numpy.IntDType

Bases: numpy.dtypes._IntegerAbstractDType

DType class corresponding to the scalar type and dtype of the same name.

Please see numpy.dtype for the typical way to create dtype instances and arrays.dtypes for additional information.

class arkouda.numpy.LongDType

Bases: numpy.dtypes._IntegerAbstractDType

DType class corresponding to the scalar type and dtype of the same name.

Please see numpy.dtype for the typical way to create dtype instances and arrays.dtypes for additional information.

class arkouda.numpy.LongDoubleDType

Bases: numpy.dtypes._FloatAbstractDType

DType class corresponding to the scalar type and dtype of the same name.

Please see numpy.dtype for the typical way to create dtype instances and arrays.dtypes for additional information.

class arkouda.numpy.LongLongDType

Bases: numpy.dtypes._IntegerAbstractDType

DType class corresponding to the scalar type and dtype of the same name.

Please see numpy.dtype for the typical way to create dtype instances and arrays.dtypes for additional information.

class arkouda.numpy.NUMBER_FORMAT_STRINGS

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s

(key, value) pairs

dict(iterable) -> new dictionary initialized as if via:

d = {} for k, v in iterable:

d[k] = v

dict(**kwargs) -> new dictionary initialized with the name=value pairs

in the keyword argument list. For example: dict(one=1, two=2)

clear()

Remove all items from the dict.

copy()

Return a shallow copy of the dict.

fromkeys(iterable, value=None, /)

Create a new dictionary with keys from iterable and values set to value.

get(key, default=None, /)

Return the value for key if key is in the dictionary, else default.

items()

Return a set-like object providing a view on the dict’s items.

keys()

Return a set-like object providing a view on the dict’s keys.

pop(*args, **kwargs)

D.pop(k[,d]) -> v, remove specified key and return the corresponding value.

If the key is not found, return the default if given; otherwise, raise a KeyError.

popitem()

Remove and return a (key, value) pair as a 2-tuple.

Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.

setdefault(key, default=None, /)

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

update(*args, **kwargs)

D.update([E, ]**F) -> None. Update D from mapping/iterable E and F. If E is present and has a .keys() method, then does: for k in E.keys(): D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values()

Return an object providing a view on the dict’s values.

exception arkouda.numpy.NonUniqueError[source]

Bases: ValueError

Exception raised when duplicate values are found in a set of keys that are expected to be unique. This is typically raised in lookup and alignment operations that assume a one-to-one mapping between keys and values.

Examples

>>> from arkouda.numpy.alignment import NonUniqueError
>>> raise NonUniqueError("Duplicate values found in key array.")
Traceback (most recent call last):
    ...
arkouda.numpy.alignment.NonUniqueError: Duplicate values found in key array.
class arkouda.numpy.NumericDTypes

Build an immutable unordered collection of unique elements.

copy()

Return a shallow copy of a set.

difference(*others)

Return a new set with elements in the set that are not in the others.

intersection(*others)

Return a new set with elements common to the set and all others.

isdisjoint(other, /)

Return True if two sets have a null intersection.

issubset(other, /)

Report whether another set contains this set.

issuperset(other, /)

Report whether this set contains another set.

symmetric_difference(other, /)

Return a new set with elements in either the set or other but not both.

union(*others)

Return a new set with elements from the set and all others.

class arkouda.numpy.ObjectDType

Bases: numpy.dtype

DType class corresponding to the scalar type and dtype of the same name.

Please see numpy.dtype for the typical way to create dtype instances and arrays.dtypes for additional information.

exception arkouda.numpy.RegistrationError[source]

Bases: Exception

Error/Exception used when the Arkouda Server cannot register an object.

class arkouda.numpy.ScalarDTypes

Build an immutable unordered collection of unique elements.

copy()

Return a shallow copy of a set.

difference(*others)

Return a new set with elements in the set that are not in the others.

intersection(*others)

Return a new set with elements common to the set and all others.

isdisjoint(other, /)

Return True if two sets have a null intersection.

issubset(other, /)

Report whether another set contains this set.

issuperset(other, /)

Report whether this set contains another set.

symmetric_difference(other, /)

Return a new set with elements in either the set or other but not both.

union(*others)

Return a new set with elements from the set and all others.

class arkouda.numpy.ScalarType

Built-in immutable sequence.

If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.

If the argument is a tuple, the return value is the same object.

count(value, /)

Return number of occurrences of value.

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

class arkouda.numpy.SegArray(segments, values, lengths=None, grouping=None)[source]
AND(x=None)[source]
OR(x=None)[source]
XOR(x=None)[source]
aggregate(op, x=None)[source]
all(x=None)[source]
any(x=None)[source]
append(other, axis=0)[source]

Append other to self, either vertically (axis=0, length of resulting SegArray increases), or horizontally (axis=1, each sub-array of other appends to the corresponding sub-array of self).

Parameters:
  • other (SegArray) – Array of sub-arrays to append

  • axis (0 or 1) – Whether to append vertically (0) or horizontally (1). If axis=1, other must be same size as self.

Returns:

axis=0: New SegArray containing all sub-arrays axis=1: New SegArray of same length, with pairs of sub-arrays concatenated

Return type:

SegArray

append_single(x, prepend=False)[source]

Append a single value to each sub-array.

Parameters:

x (pdarray or scalar) – Single value to append to each sub-array

Returns:

Copy of original SegArray with values from x appended to each sub-array

Return type:

SegArray

argmax(x=None)[source]
argmin(x=None)[source]
classmethod concat(x, axis=0, ordered=True)[source]

Concatenate a sequence of SegArrays.

Parameters:
  • x (sequence of SegArray) – The SegArrays to concatenate

  • axis (0 or 1) – Select vertical (0) or horizontal (1) concatenation. If axis=1, all SegArrays must have same size.

  • ordered (bool) – Must be True. This option is present for compatibility only, because unordered concatenation is not yet supported.

Returns:

The input arrays joined into one SegArray

Return type:

SegArray

copy()[source]

Return a deep copy.

dtype
filter(filter, discard_empty: bool = False)[source]

Filter values out of the SegArray object.

Parameters:
  • filter (pdarray, list, or value) – The value/s to be filtered out of the SegArray

  • discard_empty (bool) – Defaults to False. When True, empty segments are removed from the return SegArray

Return type:

SegArray

classmethod from_multi_array(m)[source]

Construct a SegArray from a list of columns. This essentially transposes the input, resulting in an array of rows.

Parameters:

m (list of pdarray or Strings) – List of columns, the rows of which will form the sub-arrays of the output

Returns:

Array of rows of input

Return type:

SegArray

classmethod from_return_msg(rep_msg) SegArray[source]
get_jth(j, return_origins=True, compressed=False, default=0)[source]

Select the j-th element of each sub-array, where possible.

Parameters:
  • j (int) – The index of the value to get from each sub-array. If j is negative, it counts backwards from the end of each sub-array.

  • return_origins (bool) – If True, return a logical index indicating where j is in bounds

  • compressed (bool) – If False, return array is same size as self, with default value where j is out of bounds. If True, the return array only contains values where j is in bounds.

  • default (scalar) – When compressed=False, the value to return when j is out of bounds for the sub-array

Returns:

valpdarray

compressed=False: The j-th value of each sub-array where j is in bounds and the default value where j is out of bounds. compressed=True: The j-th values of only the sub-arrays where j is in bounds

origin_indicespdarray, bool

A Boolean array that is True where j is in bounds for the sub-array.

Return type:

pdarray, pdarray|bool

Notes

If values are Strings, only the compressed format is supported.

get_length_n(n, return_origins=True)[source]

Return all sub-arrays of length n, as a list of columns.

Parameters:
  • n (int) – Length of sub-arrays to select

  • return_origins (bool) – Return a logical index indicating which sub-arrays are length n

Returns:

columnslist of pdarray

An n-long list of pdarray, where each row is one of the n-long sub-arrays from the SegArray. The number of rows is the number of True values in the returned mask.

origin_indicespdarray, bool

Array of bool for each element of the SegArray, True where sub-array has length n.

Return type:

List of pdarray, pdarray|bool

get_ngrams(n, return_origins=True)[source]

Return all n-grams from all sub-arrays.

Parameters:
  • n (int) – Length of n-gram

  • return_origins (bool) – If True, return an int64 array indicating which sub-array each returned n-gram came from.

Returns:

ngramslist of pdarray

An n-long list of pdarrays, essentially a table where each row is an n-gram.

origin_indicespdarray, int

The index of the sub-array from which the corresponding n-gram originated

Return type:

pdarray, pdarray|int

get_prefixes(n, return_origins=True, proper=True)[source]

Return all sub-array prefixes of length n (for sub-arrays that are at least n+1 long).

Parameters:
  • n (int) – Length of suffix

  • return_origins (bool) – If True, return a logical index indicating which sub-arrays were long enough to return an n-prefix

  • proper (bool) – If True, only return proper prefixes, i.e. from sub-arrays that are at least n+1 long. If False, allow the entire sub-array to be returned as a prefix.

Returns:

prefixeslist of pdarray

An n-long list of pdarrays, essentially a table where each row is an n-prefix. The number of rows is the number of True values in the returned mask.

origin_indicespdarray, bool

Boolean array that is True where the sub-array was long enough to return an n-suffix, False otherwise.

Return type:

List of pdarray, pdarray|bool

get_suffixes(n, return_origins=True, proper=True)[source]

Return the n-long suffix of each sub-array, where possible.

Parameters:
  • n (int) – Length of suffix

  • return_origins (bool) – If True, return a logical index indicating which sub-arrays were long enough to return an n-suffix

  • proper (bool) – If True, only return proper suffixes, i.e. from sub-arrays that are at least n+1 long. If False, allow the entire sub-array to be returned as a suffix.

Returns:

suffixeslist of pdarray

An n-long list of pdarrays, essentially a table where each row is an n-suffix. The number of rows is the number of True values in the returned mask.

origin_indicespdarray, bool

Boolean array that is True where the sub-array was long enough to return an n-suffix, False otherwise.

Return type:

List of pdarray, pdarray|bool

property grouping
hash() Tuple[arkouda.numpy.pdarrayclass.pdarray, arkouda.numpy.pdarrayclass.pdarray][source]

Compute a 128-bit hash of each segment.

Returns:

A tuple of two int64 pdarrays. The ith hash value is the concatenation of the ith values from each array.

Return type:

Tuple[pdarray,pdarray]

intersect(other)[source]

Computes the intersection of 2 SegArrays.

Parameters:

other (SegArray) – SegArray to compute against

Returns:

Segments are the 1d intersections of the segments of self and other

Return type:

SegArray

Examples

>>> import arkouda as ak
>>> a = [1, 2, 3, 1, 4]
>>> b = [3, 1, 4, 5]
>>> c = [1, 3, 3, 5]
>>> d = [2, 2, 4]
>>> seg_a = ak.SegArray(ak.array([0, len(a)]), ak.array(a+b))
>>> seg_b = ak.SegArray(ak.array([0, len(c)]), ak.array(c+d))
>>> seg_a.intersect(seg_b)
SegArray([
[1 3]
[4]
])
is_registered() bool[source]

Check if the name of the SegArray object is registered in the Symbol Table.

Returns:

True if SegArray is registered, false if not

Return type:

bool

logger
max(x=None)[source]
mean(x=None)[source]
min(x=None)[source]
property nbytes

The size of the segarray in bytes.

Returns:

The size of the segarray in bytes.

Return type:

int

property non_empty
nunique(x=None)[source]
objType = 'SegArray'
prepend_single(x)[source]
prod(x=None)[source]
classmethod read_hdf(prefix_path, dataset='segarray')[source]

Load a saved SegArray from HDF5. All arguments must match what was supplied to SegArray.save().

Parameters:
  • prefix_path (str) – Directory and filename prefix

  • dataset (str) – Name prefix for saved data within the HDF5 files

Return type:

SegArray

register(user_defined_name)[source]

Register this SegArray object and underlying components with the Arkouda server.

Parameters:

user_defined_name (str) – user defined name which this SegArray object will be registered under

Returns:

The same SegArray which is now registered with the arkouda server and has an updated name. This is an in-place modification, the original is returned to support a fluid programming style. Please note you cannot register two different SegArrays with the same name.

Return type:

SegArray

Raises:

RegistrationError – Raised if the server could not register the SegArray object

Notes

Objects registered with the server are immune to deletion until they are unregistered.

registered_name: str | None = None
remove_repeats(return_multiplicity=False)[source]

Condense sequences of repeated values within a sub-array to a single value.

Parameters:

return_multiplicity (bool) – If True, also return the number of times each value was repeated.

Returns:

norepeatsSegArray

Sub-arrays with runs of repeated values replaced with single value

multiplicitySegArray

If return_multiplicity=True, this array contains the number of times each value in the returned SegArray was repeated in the original SegArray.

Return type:

Segarray, Segarray

segments
set_jth(i, j, v)[source]

Set the j-th element of each sub-array in a subset.

Parameters:
  • i (pdarray, int) – Indices of sub-arrays to set j-th element

  • j (int) – Index of value to set in each sub-array. If j is negative, it counts backwards from the end of the sub-array.

  • v (pdarray or scalar) – The value(s) to set. If v is a pdarray, it must have same length as i.

Raises:

ValueError – If j is out of bounds in any of the sub-arrays specified by i.

setdiff(other)[source]

Computes the set difference of 2 SegArrays.

Parameters:

other (SegArray) – SegArray to compute against

Returns:

Segments are the 1d set difference of the segments of self and other

Return type:

SegArray

Examples

>>> import arkouda as ak
>>> a = [1, 2, 3, 1, 4]
>>> b = [3, 1, 4, 5]
>>> c = [1, 3, 3, 5]
>>> d = [2, 2, 4]
>>> seg_a = ak.SegArray(ak.array([0, len(a)]), ak.array(a+b))
>>> seg_b = ak.SegArray(ak.array([0, len(c)]), ak.array(c+d))
>>> seg_a.setdiff(seg_b)
SegArray([
[2 4]
[1 3 5]
])
setxor(other)[source]

Computes the symmetric difference of 2 SegArrays.

Parameters:

other (SegArray) – SegArray to compute against

Returns:

Segments are the 1d symmetric difference of the segments of self and other

Return type:

SegArray

Examples

>>> import arkouda as ak
>>> a = [1, 2, 3, 1, 4]
>>> b = [3, 1, 4, 5]
>>> c = [1, 3, 3, 5]
>>> d = [2, 2, 4]
>>> seg_a = ak.SegArray(ak.array([0, len(a)]), ak.array(a+b))
>>> seg_b = ak.SegArray(ak.array([0, len(c)]), ak.array(c+d))
>>> seg_a.setxor(seg_b)
SegArray([
[2 4 5]
[1 2 3 5]
])
size
sum(x=None)[source]
to_hdf(prefix_path, dataset: str = 'segarray', mode: Literal['truncate', 'append'] = 'truncate', file_type: Literal['single', 'distribute'] = 'distribute')[source]

Save the SegArray to HDF5. The result is a collection of HDF5 files, one file per locale of the arkouda server, where each filename starts with prefix_path.

Parameters:
  • prefix_path (str) – Directory and filename prefix that all output files will share

  • dataset (str) – Name prefix for saved data within the HDF5 file

  • mode ({'truncate', 'append'}) – By default, truncate (overwrite) output files, if they exist. If ‘append’, add data as a new column to existing files.

  • file_type ({"single", "distribute"}) – Default: “distribute” When set to single, dataset is written to a single file. When distribute, dataset is written on a file per locale. This is only supported by HDF5 files and will have no impact of Parquet Files.

Return type:

None

See also

load

to_ndarray()[source]

Convert the array into a numpy.ndarray containing sub-arrays.

Returns:

A numpy ndarray with the same sub-arrays (also numpy.ndarray) as this array

Return type:

np.ndarray

See also

array, tolist

Examples

>>> import arkouda as ak
>>> segarr = ak.SegArray(ak.array([0, 4, 7]), ak.arange(12))
>>> segarr.to_ndarray()
array([array([0, 1, 2, 3]), array([4, 5, 6]), array([ 7,  8,  9, 10, 11])],
  dtype=object)
>>> type(segarr.to_ndarray())
<class 'numpy.ndarray'>
to_parquet(prefix_path, dataset='segarray', mode: Literal['truncate', 'append'] = 'truncate', compression: str | None = None)[source]

Save the SegArray object to Parquet. The result is a collection of files, one file per locale of the arkouda server, where each filename starts with prefix_path. Each locale saves its chunk of the object to its corresponding file.

Parameters:
  • prefix_path (str) – Directory and filename prefix that all output files share

  • dataset (str) – Name of the dataset to create in files (must not already exist)

  • mode ({'truncate', 'append'}) – Deprecated. Parameter kept to maintain functionality of other calls. Only Truncate supported. By default, truncate (overwrite) output files, if they exist. If ‘append’, attempt to create new dataset in existing files.

  • compression (str (Optional)) – (None | “snappy” | “gzip” | “brotli” | “zstd” | “lz4”) Sets the compression type used with Parquet files

Return type:

string message indicating result of save operation

Raises:
  • RuntimeError – Raised if a server-side error is thrown saving the pdarray

  • ValueError – If write mode is not Truncate.

Notes

  • Append mode for Parquet has been deprecated. It was not implemented for SegArray.

  • The prefix_path must be visible to the arkouda server and the user must

have write permission. - Output files have names of the form <prefix_path>_LOCALE<i>, where <i> ranges from 0 to numLocales for file_type=’distribute’. - If any of the output files already exist and the mode is ‘truncate’, they will be overwritten. If the mode is ‘append’ and the number of output files is less than the number of locales or a dataset with the same name already exists, a RuntimeError will result. - Any file extension can be used.The file I/O does not rely on the extension to determine the file format.

tolist()[source]

Convert the segarray into a list containing sub-arrays.

Returns:

A list with the same sub-arrays (also list) as this segarray

Return type:

list

See also

to_ndarray

Examples

>>> import arkouda as ak
>>> segarr = ak.SegArray(ak.array([0, 4, 7]), ak.arange(12))
>>> segarr.tolist()
[[0, 1, 2, 3], [4, 5, 6], [7, 8, 9, 10, 11]]
>>> type(segarr.tolist())
<class 'list'>
transfer(hostname: str, port: arkouda.numpy.dtypes.int_scalars)[source]

Send a Segmented Array to a different Arkouda server.

Parameters:
  • hostname (str) – The hostname where the Arkouda server intended to receive the Segmented Array is running.

  • port (int_scalars) – The port to send the array over. This needs to be an open port (i.e., not one that the Arkouda server is running on). This will open up numLocales ports, each of which in succession, so will use ports of the range {port..(port+numLocales)} (e.g., running an Arkouda server of 4 nodes, port 1234 is passed as port, Arkouda will use ports 1234, 1235, 1236, and 1237 to send the array data). This port much match the port passed to the call to ak.receive_array().

Return type:

A message indicating a complete transfer

Raises:
  • ValueError – Raised if the op is not within the pdarray.BinOps set

  • TypeError – Raised if other is not a pdarray or the pdarray.dtype is not a supported dtype

union(other)[source]

Computes the union of 2 SegArrays.

Parameters:

other (SegArray) – SegArray to compute against

Returns:

Segments are the 1d union of the segments of self and other

Return type:

SegArray

Examples

>>> import arkouda as ak
>>> a = [1, 2, 3, 1, 4]
>>> b = [3, 1, 4, 5]
>>> c = [1, 3, 3, 5]
>>> d = [2, 2, 4]
>>> seg_a = ak.SegArray(ak.array([0, len(a)]), ak.array(a+b))
>>> seg_b = ak.SegArray(ak.array([0, len(c)]), ak.array(c+d))
>>> seg_a.union(seg_b)
SegArray([
[1 2 3 4 5]
[1 2 3 4 5]
])
unique(x=None) SegArray[source]

Return sub-arrays of unique values.

Parameters:

x (pdarray) – The values to unique, per group. By default, the values of this SegArray’s sub-arrays.

Returns:

Same number of sub-arrays as original SegArray, but elements in sub-array are unique and in sorted order.

Return type:

SegArray

unregister()[source]

Unregister this SegArray object in the arkouda server which was previously registered using register() and/or attached to using attach().

Raises:

RuntimeError – Raised if the server could not unregister the SegArray object from the Symbol Table

Notes

Objects registered with the server are immune to deletion until they are unregistered.

update_hdf(prefix_path: str, dataset: str = 'segarray', repack: bool = True)[source]

Overwrite the dataset with the name provided with this SegArray object. If the dataset does not exist it is added.

Parameters:
  • prefix_path (str) – Directory and filename prefix that all output files share

  • dataset (str) – Name of the dataset to create in files

  • repack (bool) – Default: True HDF5 does not release memory on delete. When True, the inaccessible data (that was overwritten) is removed. When False, the data remains, but is inaccessible. Setting to false will yield better performance, but will cause file sizes to expand.

Raises:

RuntimeError – Raised if a server-side error is thrown saving the SegArray

Notes

  • If file does not contain File_Format attribute to indicate how it was saved, the file name is checked for _LOCALE#### to determine if it is distributed.

  • If the dataset provided does not exist, it will be added

  • Because HDF5 deletes do not release memory, this will create a copy of the file with the new data

valsize
values
class arkouda.numpy.SeriesDTypes

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s

(key, value) pairs

dict(iterable) -> new dictionary initialized as if via:

d = {} for k, v in iterable:

d[k] = v

dict(**kwargs) -> new dictionary initialized with the name=value pairs

in the keyword argument list. For example: dict(one=1, two=2)

clear()

Remove all items from the dict.

copy()

Return a shallow copy of the dict.

fromkeys(iterable, value=None, /)

Create a new dictionary with keys from iterable and values set to value.

get(key, default=None, /)

Return the value for key if key is in the dictionary, else default.

items()

Return a set-like object providing a view on the dict’s items.

keys()

Return a set-like object providing a view on the dict’s keys.

pop(*args, **kwargs)

D.pop(k[,d]) -> v, remove specified key and return the corresponding value.

If the key is not found, return the default if given; otherwise, raise a KeyError.

popitem()

Remove and return a (key, value) pair as a 2-tuple.

Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.

setdefault(key, default=None, /)

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

update(*args, **kwargs)

D.update([E, ]**F) -> None. Update D from mapping/iterable E and F. If E is present and has a .keys() method, then does: for k in E.keys(): D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values()

Return an object providing a view on the dict’s values.

class arkouda.numpy.ShortDType

Bases: numpy.dtypes._IntegerAbstractDType

DType class corresponding to the scalar type and dtype of the same name.

Please see numpy.dtype for the typical way to create dtype instances and arrays.dtypes for additional information.

arkouda.numpy.SortingAlgorithm
class arkouda.numpy.StrDType

Bases: numpy.dtype

DType class corresponding to the scalar type and dtype of the same name.

Please see numpy.dtype for the typical way to create dtype instances and arrays.dtypes for additional information.

class arkouda.numpy.Strings(strings_pdarray: arkouda.numpy.pdarrayclass.pdarray, bytes_size: arkouda.numpy.dtypes.int_scalars)[source]

Represents an array of strings whose data resides on the arkouda server. The user should not call this class directly; rather its instances are created by other arkouda functions.

entry

Encapsulation of a Segmented Strings array contained on the arkouda server. This is a composite of

  • offsets array: starting indices for each string

  • bytes array: raw bytes of all strings joined by nulls

Type:

pdarray

size

The number of strings in the array

Type:

int_scalars

nbytes

The total number of bytes in all strings

Type:

int_scalars

ndim

The rank of the array (currently only rank 1 arrays supported)

Type:

int_scalars

shape

The sizes of each dimension of the array

Type:

tuple

dtype

The dtype is ak.str_

Type:

type

logger

Used for all logging operations

Type:

ArkoudaLogger

Notes

Strings is composed of two pdarrays: (1) offsets, which contains the starting indices for each string and (2) bytes, which contains the raw bytes of all strings, delimited by nulls.

BinOps
argsort(algorithm: arkouda.numpy.sorting.SortingAlgorithm = SortingAlgorithm.RadixSortLSD, ascending: bool = True) arkouda.numpy.pdarrayclass.pdarray[source]

Return the permutation that sorts the Strings.

Parameters:
  • algorithm (SortingAlgorithm, default SortingAlgorithm.RadixSortLSD) – The algorithm to use for sorting.

  • ascending (bool, default True) – Whether to sort in ascending order.

Returns:

The indices that sort the Strings.

Return type:

pdarray

astype(dtype: numpy.dtype | str) arkouda.numpy.pdarrayclass.pdarray | Strings[source]

Cast values of Strings object to provided dtype.

Parameters:

dtype (np.dtype or str) – Dtype to cast to

Returns:

An arkouda pdarray with values converted to the specified data type

Return type:

pdarray

Notes

This is essentially shorthand for ak.cast(x, ‘<dtype>’) where x is a pdarray.

cached_regex_patterns() List[source]

Returns the regex patterns for which Match objects have been cached.

capitalize() Strings[source]

Return a new Strings from the original replaced with the first letter capitilzed and the remaining letters lowercase.

Returns:

Strings from the original replaced with the capitalized equivalent.

Return type:

Strings

Raises:

RuntimeError – Raised if there is a server-side error thrown.

See also

Strings.lower, String.upper, String.title

Examples

>>> import arkouda as ak
>>> strings = ak.array([f'StrINgS aRe Here {i}' for i in range(5)])
>>> strings
array(['StrINgS aRe Here 0', 'StrINgS aRe Here 1', 'StrINgS aRe Here 2', 'StrINgS aRe Here 3', 'StrINgS aRe Here 4'])
>>> strings.title()
array(['Strings Are Here 0', 'Strings Are Here 1', 'Strings Are Here 2', 'Strings Are Here 3', 'Strings Are Here 4'])
static concatenate_uniquely(strings: List[Strings]) Strings[source]

Concatenates a list of Strings into a single Strings object containing only unique strings. Order may not be preserved.

Parameters:

strings (List[Strings]) – List of segmented string objects to concatenate.

Returns:

A new Strings object containing the unique values.

Return type:

Strings

contains(substr: bytes | arkouda.numpy.dtypes.str_scalars, regex: bool = False) arkouda.numpy.pdarrayclass.pdarray[source]

Check whether each element contains the given substring.

Parameters:
  • substr (bytes or str_scalars) – The substring in the form of string or byte array to search for

  • regex (bool, default=False) – Indicates whether substr is a regular expression Note: only handles regular expressions supported by re2 (does not support lookaheads/lookbehinds)

Returns:

True for elements that contain substr, False otherwise

Return type:

pdarray

Raises:
  • TypeError – Raised if the substr parameter is not bytes or str_scalars

  • ValueError – Rasied if substr is not a valid regex

  • RuntimeError – Raised if there is a server-side error thrown

Examples

>>> import arkouda as ak
>>> strings = ak.array([f'{i} string {i}' for i in range(1, 6)])
>>> strings
array(['1 string 1', '2 string 2', '3 string 3', '4 string 4', '5 string 5'])
>>> strings.contains('string')
array([True True True True True])
>>> strings.contains('string \\d', regex=True)
array([True True True True True])
copy() Strings[source]

Return a deep copy of the Strings object.

Returns:

A deep copy of the Strings.

Return type:

Strings

decode(fromEncoding: str, toEncoding: str = 'UTF-8') Strings[source]

Return a new strings object in fromEncoding, expecting that the current Strings is encoded in toEncoding.

Parameters:
  • fromEncoding (str) – The current encoding of the strings object

  • toEncoding (str, default="UTF-8") – The encoding that the strings will be converted to, default to UTF-8

Returns:

A new Strings object in toEncoding

Return type:

Strings

Raises:

RuntimeError – Raised if there is a server-side error thrown

property dtype: numpy.dtype

Return the dtype object of the underlying data.

encode(toEncoding: str, fromEncoding: str = 'UTF-8') Strings[source]

Return a new strings object in toEncoding, expecting that the current Strings is encoded in fromEncoding.

Parameters:
  • toEncoding (str) – The encoding that the strings will be converted to

  • fromEncoding (str, default="UTF-8") – The current encoding of the strings object, default to UTF-8

Returns:

A new Strings object in toEncoding

Return type:

Strings

Raises:

RuntimeError – Raised if there is a server-side error thrown

endswith(substr: bytes | arkouda.numpy.dtypes.str_scalars, regex: bool = False) arkouda.numpy.pdarrayclass.pdarray[source]

Check whether each element ends with the given substring.

Parameters:
  • substr (bytes or str_scalars) – The suffix to search for

  • regex (bool, default=False) – Indicates whether substr is a regular expression Note: only handles regular expressions supported by re2 (does not support lookaheads/lookbehinds)

Returns:

True for elements that end with substr, False otherwise

Return type:

pdarray

Raises:
  • TypeError – Raised if the substr parameter is not bytes or str_scalars

  • ValueError – Rasied if substr is not a valid regex

  • RuntimeError – Raised if there is a server-side error thrown

Examples

>>> import arkouda as ak
>>> strings_start = ak.array([f'{i} string' for i in range(1,6)])
>>> strings_start
array(['1 string', '2 string', '3 string', '4 string', '5 string'])
>>> strings_start.endswith('ing')
array([True True True True True])
>>> strings_end = ak.array([f'string {i}' for i in range(1, 6)])
>>> strings_end
array(['string 1', 'string 2', 'string 3', 'string 4', 'string 5'])
>>> strings_end.endswith('ing \\d', regex = True)
array([True True True True True])
entry: arkouda.numpy.pdarrayclass.pdarray
equals(other) arkouda.numpy.dtypes.bool_scalars[source]

Whether Strings are the same size and all entries are equal.

Parameters:

other (Any) – object to compare.

Returns:

True if the Strings are the same, o.w. False.

Return type:

bool_scalars

Examples

>>> import arkouda as ak
>>> s = ak.array(["a", "b", "c"])
>>> s_cpy = ak.array(["a", "b", "c"])
>>> s.equals(s_cpy)
np.True_
>>> s2 = ak.array(["a", "x", "c"])
>>> s.equals(s2)
np.False_
find_locations(pattern: bytes | arkouda.numpy.dtypes.str_scalars) Tuple[arkouda.numpy.pdarrayclass.pdarray, arkouda.numpy.pdarrayclass.pdarray, arkouda.numpy.pdarrayclass.pdarray][source]

Finds pattern matches and returns pdarrays containing the number, start postitions, and lengths of matches.

Parameters:

pattern (bytes or str_scalars) – The regex pattern used to find matches

Returns:

pdarray, int64

For each original string, the number of pattern matches

pdarray, int64

The start positons of pattern matches

pdarray, int64

The lengths of pattern matches

Return type:

Tuple[pdarray, pdarray, pdarray]

Raises:
  • TypeError – Raised if the pattern parameter is not bytes or str_scalars

  • ValueError – Raised if pattern is not a valid regex

  • RuntimeError – Raised if there is a server-side error thrown

Examples

>>> import arkouda as ak
>>> strings = ak.array([f'{i} string {i}' for i in range(1, 6)])
>>> num_matches, starts, lens = strings.find_locations('\\d')
>>> num_matches
array([2 2 2 2 2])
>>> starts
array([0 9 0 9 0 9 0 9 0 9])
>>> lens
array([1 1 1 1 1 1 1 1 1 1])
findall(pattern: bytes | arkouda.numpy.dtypes.str_scalars, return_match_origins: bool = False) Strings | Tuple[source]

Return a new Strings containg all non-overlapping matches of pattern.

Parameters:
  • pattern (bytes or str_scalars) – Regex used to find matches

  • return_match_origins (bool, default=False) – If True, return a pdarray containing the index of the original string each pattern match is from

Returns:

Strings

Strings object containing only pattern matches

pdarray, int64 (optional)

The index of the original string each pattern match is from

Return type:

Union[Strings, Tuple]

Raises:
  • TypeError – Raised if the pattern parameter is not bytes or str_scalars

  • ValueError – Raised if pattern is not a valid regex

  • RuntimeError – Raised if there is a server-side error thrown

Examples

>>> import arkouda as ak
>>> strings = ak.array(['1_2___', '____', '3', '__4___5____6___7', ''])
>>> strings.findall('_+', return_match_origins=True)
(array(['_', '___', '____', '__', '___', '____', '___']), array([0 0 1 3 3 3 3]))
flatten() Strings[source]

Return a copy of the array collapsed into one dimension.

Return type:

A copy of the input array, flattened to one dimension.

Note

As multidimensional Strings are currently supported, flatten on a Strings object will always return itself.

static from_parts(offset_attrib: arkouda.numpy.pdarrayclass.pdarray | str, bytes_attrib: arkouda.numpy.pdarrayclass.pdarray | str) Strings[source]

Assemble a Strings object from separate offset and bytes arrays.

This factory method constructs a segmented Strings array by sending two separate components—offsets and values—to the Arkouda server and instructing it to assemble them into a single Strings object. Use this when offsets and byte data are created or transported independently.

Parameters:
  • offset_attrib (pdarray or str) – The array of starting positions for each string, or a string expression that can be passed to create_pdarray to build it.

  • bytes_attrib (pdarray or str) – The array of raw byte values (e.g., uint8 character codes), or a string expression that can be passed to create_pdarray to build it.

Returns:

A Strings object representing the assembled segmented strings array on the Arkouda server.

Return type:

Strings

Raises:

RuntimeError – If conversion of offset_attrib or bytes_attrib to pdarray fails, or if the server is unable to assemble the parts into a Strings.

Notes

  • Both inputs can be existing pdarray instances or arguments suitable for create_pdarray.

  • Internally uses the CMD_ASSEMBLE command to merge offsets and values.

static from_return_msg(rep_msg: str) Strings[source]

Create a Strings object from an Arkouda server response message.

Parse the server’s response descriptor and construct a Strings array with its underlying pdarray and total byte size.

Parameters:

rep_msg (str) – Server response message of the form: ` created <name> <type> <size> <ndim> <shape> <itemsize>+... bytes.size <total_bytes> ` For example: ` "created foo Strings 3 1 (3,) 8+created bytes.size 24" `

Returns:

A Strings object representing the segmented strings array on the server, initialized with the returned pdarray and byte-size metadata.

Return type:

Strings

Raises:

RuntimeError – If the response message cannot be parsed or does not match the expected format.

Examples

>>> import arkouda as ak

# Example response message (typically from generic_msg) >>> rep_msg = “created foo Strings 3 1 (3,) 8+created bytes.size 24” >>> s = ak.Strings.from_return_msg(rep_msg) >>> isinstance(s, ak.Strings) True

fullmatch(pattern: bytes | arkouda.numpy.dtypes.str_scalars) arkouda.pandas.match.Match[source]

Return a match object where elements match only if the whole string matches the regular expression pattern.

Parameters:

pattern (bytes or str_scalars) – Regex used to find matches

Returns:

Match object where elements match only if the whole string matches the regular expression pattern

Return type:

Match

Examples

>>> import arkouda as ak
>>> strings = ak.array(['1_2___', '____', '3', '__4___5____6___7', ''])
>>> strings.fullmatch('_+')
<ak.Match object: matched=False; matched=True, span=(0, 4); matched=False;
matched=False; matched=False>
get_bytes() arkouda.numpy.pdarrayclass.pdarray[source]

Getter for the bytes component (uint8 pdarray) of this Strings.

Returns:

Pdarray of bytes of the string accessed

Return type:

pdarray

Example

>>> import arkouda as ak
>>> x = ak.array(['one', 'two', 'three'])
>>> x.get_bytes()
array([111 110 101 0 116 119 111 0 116 104 114 101 101 0])
get_lengths() arkouda.numpy.pdarrayclass.pdarray[source]

Return the length of each string in the array.

Returns:

The length of each string

Return type:

pdarray

Raises:

RuntimeError – Raised if there is a server-side error thrown

get_offsets() arkouda.numpy.pdarrayclass.pdarray[source]

Getter for the offsets component (int64 pdarray) of this Strings.

Returns:

Pdarray of offsets of the string accessed

Return type:

pdarray

Example

>>> import arkouda as ak
>>> x = ak.array(['one', 'two', 'three'])
>>> x.get_offsets()
array([0 4 8])
get_prefixes(n: arkouda.numpy.dtypes.int_scalars, return_origins: bool = True, proper: bool = True) Strings | Tuple[Strings, arkouda.numpy.pdarrayclass.pdarray][source]

Return the n-long prefix of each string, where possible.

Parameters:
  • n (int_scalars) – Length of prefix

  • return_origins (bool, default=True) – If True, return a logical index indicating which strings were long enough to return an n-prefix

  • proper (bool, default=True) – If True, only return proper prefixes, i.e. from strings that are at least n+1 long. If False, allow the entire string to be returned as a prefix.

Returns:

prefixesStrings

The array of n-character prefixes; the number of elements is the number of True values in the returned mask.

origin_indicespdarray, bool

Boolean array that is True where the string was long enough to return an n-character prefix, False otherwise.

Return type:

Union[Strings, Tuple[Strings, pdarray]]

get_suffixes(n: arkouda.numpy.dtypes.int_scalars, return_origins: bool = True, proper: bool = True) Strings | Tuple[Strings, arkouda.numpy.pdarrayclass.pdarray][source]

Return the n-long suffix of each string, where possible.

Parameters:
  • n (int_scalars) – Length of suffix

  • return_origins (bool, default=True) – If True, return a logical index indicating which strings were long enough to return an n-suffix

  • proper (bool, default=True) – If True, only return proper suffixes, i.e. from strings that are at least n+1 long. If False, allow the entire string to be returned as a suffix.

Returns:

suffixesStrings

The array of n-character suffixes; the number of elements is the number of True values in the returned mask.

origin_indicespdarray, bool

Boolean array that is True where the string was long enough to return an n-character suffix, False otherwise.

Return type:

Union[Strings, Tuple[Strings, pdarray]]

group() arkouda.numpy.pdarrayclass.pdarray[source]

Return the permutation that groups the array, placing equivalent strings together. All instances of the same string are guaranteed to lie in one contiguous block of the permuted array, but the blocks are not necessarily ordered.

Returns:

The permutation that groups the array by value

Return type:

pdarray

See also

GroupBy, unique

Notes

If the arkouda server is compiled with “-sSegmentedString.useHash=true”, then arkouda uses 128-bit hash values to group strings, rather than sorting the strings directly. This method is fast, but the resulting permutation merely groups equivalent strings and does not sort them. If the “useHash” parameter is false, then a full sort is performed.

Raises:

RuntimeError – Raised if there is a server-side error in executing group request or creating the pdarray encapsulating the return message

hash() Tuple[arkouda.numpy.pdarrayclass.pdarray, arkouda.numpy.pdarrayclass.pdarray][source]

Compute a 128-bit hash of each string.

Returns:

A tuple of two int64 pdarrays. The ith hash value is the concatenation of the ith values from each array.

Return type:

Tuple[pdarray,pdarray]

Notes

The implementation uses SipHash128, a fast and balanced hash function (used by Python for dictionaries and sets). For realistic numbers of strings (up to about 10**15), the probability of a collision between two 128-bit hash values is negligible.

property inferred_type: str

Return a string of the type inferred from the values.

info() str[source]

Return a JSON formatted string containing information about all components of self.

Returns:

JSON string containing information about all components of self

Return type:

str

is_registered() numpy.bool_[source]

Return True iff the object is contained in the registry.

Returns:

Indicates if the object is contained in the registry

Return type:

bool

Raises:

RuntimeError – Raised if there’s a server-side error thrown

isalnum() arkouda.numpy.pdarrayclass.pdarray[source]

Return a boolean pdarray where index i indicates whether string i of the Strings is alphanumeric.

Returns:

True for elements that are alphanumeric, False otherwise

Return type:

pdarray

Raises:

RuntimeError – Raised if there is a server-side error thrown

Examples

>>> import arkouda as ak
>>> not_alnum = ak.array([f'%Strings {i}' for i in range(3)])
>>> alnum = ak.array([f'Strings{i}' for i in range(3)])
>>> strings = ak.concatenate([not_alnum, alnum])
>>> strings
array(['%Strings 0', '%Strings 1', '%Strings 2', 'Strings0', 'Strings1', 'Strings2'])
>>> strings.isalnum()
array([False False False True True True])
isalpha() arkouda.numpy.pdarrayclass.pdarray[source]

Return a boolean pdarray where index i indicates whether string i of the Strings is alphabetic. This means there is at least one character, and all the characters are alphabetic.

Returns:

True for elements that are alphabetic, False otherwise

Return type:

pdarray

Raises:

RuntimeError – Raised if there is a server-side error thrown

Examples

>>> import arkouda as ak
>>> not_alpha = ak.array([f'%Strings {i}' for i in range(3)])
>>> alpha = ak.array(['StringA','StringB','StringC'])
>>> strings = ak.concatenate([not_alpha, alpha])
>>> strings
array(['%Strings 0', '%Strings 1', '%Strings 2', 'StringA', 'StringB', 'StringC'])
>>> strings.isalpha()
array([False False False True True True])
isdecimal() arkouda.numpy.pdarrayclass.pdarray[source]

Return a boolean pdarray where index i indicates whether string i of the Strings has all decimal characters.

Returns:

True for elements that are decimals, False otherwise

Return type:

pdarray

Raises:

RuntimeError – Raised if there is a server-side error thrown

See also

Strings.isdigit

Examples

>>> import arkouda as ak
>>> not_decimal = ak.array([f'Strings {i}' for i in range(3)])
>>> decimal = ak.array([f'12{i}' for i in range(3)])
>>> strings = ak.concatenate([not_decimal, decimal])
>>> strings
array(['Strings 0', 'Strings 1', 'Strings 2', '120', '121', '122'])
>>> strings.isdecimal()
array([False False False True True True])

Special Character Examples

>>> special_strings = ak.array(["3.14", "0", "²", "2³₇", "2³x₇"])
>>> special_strings
array(['3.14', '0', '²', '2³₇', '2³x₇'])
>>> special_strings.isdecimal()
array([False True False False False])
isdigit() arkouda.numpy.pdarrayclass.pdarray[source]

Return a boolean pdarray where index i indicates whether string i of the Strings has all digit characters.

Returns:

True for elements that are digits, False otherwise

Return type:

pdarray

Raises:

RuntimeError – Raised if there is a server-side error thrown

Examples

>>> import arkouda as ak
>>> not_digit = ak.array([f'Strings {i}' for i in range(3)])
>>> digit = ak.array([f'12{i}' for i in range(3)])
>>> strings = ak.concatenate([not_digit, digit])
>>> strings
array(['Strings 0', 'Strings 1', 'Strings 2', '120', '121', '122'])
>>> strings.isdigit()
array([False False False True True True])

Special Character Examples

>>> special_strings = ak.array(["3.14", "0", "²", "2³₇", "2³x₇"])
>>> special_strings
array(['3.14', '0', '²', '2³₇', '2³x₇'])
>>> special_strings.isdigit()
array([False True True True False])
isempty() arkouda.numpy.pdarrayclass.pdarray[source]

Return a boolean pdarray where index i indicates whether string i of the Strings is empty.

True for elements that are the empty string, False otherwise

Returns:

True for elements that are digits, False otherwise

Return type:

pdarray

Raises:

RuntimeError – Raised if there is a server-side error thrown

Examples

>>> import arkouda as ak
>>> not_empty = ak.array([f'Strings {i}' for i in range(3)])
>>> empty = ak.array(['' for i in range(3)])
>>> strings = ak.concatenate([not_empty, empty])
>>> strings
array(['Strings 0', 'Strings 1', 'Strings 2', '', '', ''])
>>> strings.isempty()
array([False False False True True True])
islower() arkouda.numpy.pdarrayclass.pdarray[source]

Return a boolean pdarray where index i indicates whether string i of the Strings is entirely lowercase.

Returns:

True for elements that are entirely lowercase, False otherwise

Return type:

pdarray

Raises:

RuntimeError – Raised if there is a server-side error thrown

See also

Strings.isupper

Examples

>>> import arkouda as ak
>>> lower = ak.array([f'strings {i}' for i in range(3)])
>>> upper = ak.array([f'STRINGS {i}' for i in range(3)])
>>> strings = ak.concatenate([lower, upper])
>>> strings
array(['strings 0', 'strings 1', 'strings 2', 'STRINGS 0', 'STRINGS 1', 'STRINGS 2'])
>>> strings.islower()
array([True True True False False False])
isnumeric() arkouda.numpy.pdarrayclass.pdarray[source]

Return a boolean pdarray where index i indicates whether string i of the Strings has all numeric characters. There are 1922 unicode characters that qualify as numeric, including the digits 0 through 9, superscripts and subscripted digits, special characters with the digits encircled or enclosed in parens, “vulgar fractions,” and more.

Returns:

True for elements that are numerics, False otherwise

Return type:

pdarray

Raises:

RuntimeError – Raised if there is a server-side error thrown

Examples

>>> import arkouda as ak
>>> not_numeric = ak.array([f'Strings {i}' for i in range(3)])
>>> numeric = ak.array([f'12{i}' for i in range(3)])
>>> strings = ak.concatenate([not_numeric, numeric])
>>> strings
array(['Strings 0', 'Strings 1', 'Strings 2', '120', '121', '122'])
>>> strings.isnumeric()
array([False False False True True True])

Special Character Examples

>>> special_strings = ak.array(["3.14", "0", "²", "2³₇", "2³x₇"])
>>> special_strings
array(['3.14', '0', '²', '2³₇', '2³x₇'])
>>> special_strings.isnumeric()
array([False True True True False])
isspace() arkouda.numpy.pdarrayclass.pdarray[source]

Return a boolean pdarray where index i indicates whether string i has all whitespace characters (‘ ’, ‘ ’, ‘

’, ‘ ’, ‘ ’, ‘ ’).

pdarray

True for elements that are whitespace, False otherwise

RuntimeError

Raised if there is a server-side error thrown

Strings.islower Strings.isupper Strings.istitle

>>> import arkouda as ak
>>> not_space = ak.array([f'Strings {i}' for i in range(3)])
>>> space = ak.array([' ', '\t', '\n', '\v', '\f', '\r', ' \t\n\v\f\r'])
>>> strings = ak.concatenate([not_space, space])
>>> strings
array(['Strings 0', 'Strings 1', 'Strings 2', ' ', 'u0009', 'n', 'u000B', 'u000C', 'u000D', ' u0009nu000Bu000Cu000D'])
>>> strings.isspace()
array([False False False True True True True True True True])
istitle() arkouda.numpy.pdarrayclass.pdarray[source]

Return a boolean pdarray where index i indicates whether string i of the Strings is titlecase.

Returns:

True for elements that are titlecase, False otherwise

Return type:

pdarray

Raises:

RuntimeError – Raised if there is a server-side error thrown

Examples

>>> import arkouda as ak
>>> mixed = ak.array([f'sTrINgs {i}' for i in range(3)])
>>> title = ak.array([f'Strings {i}' for i in range(3)])
>>> strings = ak.concatenate([mixed, title])
>>> strings
array(['sTrINgs 0', 'sTrINgs 1', 'sTrINgs 2', 'Strings 0', 'Strings 1', 'Strings 2'])
>>> strings.istitle()
array([False False False True True True])
isupper() arkouda.numpy.pdarrayclass.pdarray[source]

Return a boolean pdarray where index i indicates whether string i of the Strings is entirely uppercase.

Returns:

True for elements that are entirely uppercase, False otherwise

Return type:

pdarray

Raises:

RuntimeError – Raised if there is a server-side error thrown

See also

Strings.islower

Examples

>>> import arkouda as ak
>>> lower = ak.array([f'strings {i}' for i in range(3)])
>>> upper = ak.array([f'STRINGS {i}' for i in range(3)])
>>> strings = ak.concatenate([lower, upper])
>>> strings
array(['strings 0', 'strings 1', 'strings 2', 'STRINGS 0', 'STRINGS 1', 'STRINGS 2'])
>>> strings.isupper()
array([False False False True True True])
logger: arkouda.logger.ArkoudaLogger
lower() Strings[source]

Return a new Strings with all uppercase characters from the original replaced with their lowercase equivalent.

Returns:

Strings with all uppercase characters from the original replaced with their lowercase equivalent

Return type:

Strings

Raises:

RuntimeError – Raised if there is a server-side error thrown

See also

Strings.upper

Examples

>>> import arkouda as ak
>>> strings = ak.array([f'StrINgS {i}' for i in range(5)])
>>> strings
array(['StrINgS 0', 'StrINgS 1', 'StrINgS 2', 'StrINgS 3', 'StrINgS 4'])
>>> strings.lower()
array(['strings 0', 'strings 1', 'strings 2', 'strings 3', 'strings 4'])
lstick(other: Strings, delimiter: bytes | arkouda.numpy.dtypes.str_scalars = '') Strings[source]

Join the strings from another array onto the left of the strings of this array, optionally inserting a delimiter. Warning: This function is experimental and not guaranteed to work.

Parameters:
  • other (Strings) – The strings to join onto self’s strings

  • delimiter (bytes or str_scalars, default="") – String inserted between self and other

Returns:

The array of joined strings, as other + self

Return type:

Strings

Raises:
  • TypeError – Raised if the delimiter parameter is neither bytes nor a str or if the other parameter is not a Strings instance

  • RuntimeError – Raised if there is a server-side error thrown

See also

stick, peel, rpeel

Examples

>>> import arkouda as ak
>>> s = ak.array(['a', 'c', 'e'])
>>> t = ak.array(['b', 'd', 'f'])
>>> s.lstick(t, delimiter='.')
array(['b.a', 'd.c', 'f.e'])
match(pattern: bytes | arkouda.numpy.dtypes.str_scalars) arkouda.pandas.match.Match[source]

Return a match object where elements match only if the beginning of the string matches the regular expression pattern.

Parameters:

pattern (bytes or str_scalars) – Regex used to find matches

Returns:

Match object where elements match only if the beginning of the string matches the regular expression pattern

Return type:

Match

Examples

>>> import arkouda as ak
>>> strings = ak.array(['1_2___', '____', '3', '__4___5____6___7', ''])
>>> strings.match('_+')
<ak.Match object: matched=False; matched=True, span=(0, 4); matched=False;
matched=True, span=(0, 2); matched=False>
nbytes: arkouda.numpy.dtypes.int_scalars
ndim: arkouda.numpy.dtypes.int_scalars
objType = 'Strings'
peel(delimiter: bytes | arkouda.numpy.dtypes.str_scalars, times: arkouda.numpy.dtypes.int_scalars = 1, includeDelimiter: bool = False, keepPartial: bool = False, fromRight: bool = False, regex: bool = False) Tuple[Strings, Strings][source]

Peel off one or more delimited fields from each string (similar to string.partition), returning two new arrays of strings. Warning: This function is experimental and not guaranteed to work.

Parameters:
  • delimiter (bytes or str_scalars) – The separator where the split will occur

  • times (int_scalars, default=1) – The number of times the delimiter is sought, i.e. skip over the first (times-1) delimiters

  • includeDelimiter (bool, default=False) – If true, append the delimiter to the end of the first return array. By default, it is prepended to the beginning of the second return array.

  • keepPartial (bool, default=False) – If true, a string that does not contain <times> instances of the delimiter will be returned in the first array. By default, such strings are returned in the second array.

  • fromRight (bool, default=False) – If true, peel from the right instead of the left (see also rpeel)

  • regex (bool, default=False) – Indicates whether delimiter is a regular expression Note: only handles regular expressions supported by re2 (does not support lookaheads/lookbehinds)

Returns:

left: Strings

The field(s) peeled from the end of each string (unless fromRight is true)

right: Strings

The remainder of each string after peeling (unless fromRight is true)

Return type:

Tuple[Strings, Strings]

Raises:
  • TypeError – Raised if the delimiter parameter is not byte or str_scalars, if times is not int64, or if includeDelimiter, keepPartial, or fromRight is not bool

  • ValueError – Raised if times is < 1 or if delimiter is not a valid regex

  • RuntimeError – Raised if there is a server-side error thrown

See also

rpeel, stick, lstick

Examples

>>> import arkouda as ak
>>> s = ak.array(['a.b', 'c.d', 'e.f.g'])
>>> s.peel('.')
(array(['a', 'c', 'e']), array(['b', 'd', 'f.g']))
>>> s.peel('.', includeDelimiter=True)
(array(['a.', 'c.', 'e.']), array(['b', 'd', 'f.g']))
>>> s.peel('.', times=2)
(array(['', '', 'e.f']), array(['a.b', 'c.d', 'g']))
>>> s.peel('.', times=2, keepPartial=True)
(array(['a.b', 'c.d', 'e.f']), array(['', '', 'g']))
pretty_print_info() None[source]

Print information about all components of self in a human readable format.

purge_cached_regex_patterns() None[source]

Purges cached regex patterns.

regex_split(pattern: bytes | arkouda.numpy.dtypes.str_scalars, maxsplit: int = 0, return_segments: bool = False) Strings | Tuple[source]

Return a new Strings split by the occurrences of pattern.

If maxsplit is nonzero, at most maxsplit splits occur.

Parameters:
  • pattern (bytes or str_scalars) – Regex used to split strings into substrings

  • maxsplit (int, default=0) – The max number of pattern match occurences in each element to split. The default maxsplit=0 splits on all occurences

  • return_segments (bool, default=False) – If True, return mapping of original strings to first substring in return array.

Returns:

Strings

Substrings with pattern matches removed

pdarray, int64 (optional)

For each original string, the index of first corresponding substring in the return array

Return type:

Union[Strings, Tuple]

Examples

>>> import arkouda as ak
>>> strings = ak.array(['1_2___', '____', '3', '__4___5____6___7', ''])
>>> strings.regex_split('_+', maxsplit=2, return_segments=True)
(array(['1', '2', '', '', '', '3', '', '4', '5____6___7', '']), array([0 3 5 6 9]))
register(user_defined_name: str) Strings[source]

Register this Strings object with a user defined name in the arkouda server so it can be attached to later using Strings.attach().

This is an in-place operation, registering a Strings object more than once will update the name in the registry and remove the previously registered name. A name can only be registered to one object at a time.

Parameters:

user_defined_name (str) – user defined name which the Strings object is to be registered under

Returns:

The same Strings object which is now registered with the arkouda server and has an updated name. This is an in-place modification, the original is returned to support a fluid programming style. Please note you cannot register two different objects with the same name.

Return type:

Strings

Raises:
  • TypeError – Raised if user_defined_name is not a str

  • RegistrationError – If the server was unable to register the Strings object with the user_defined_name If the user is attempting to register more than one object with the same name, the former should be unregistered first to free up the registration name.

See also

attach, unregister

Notes

Registered names/Strings objects in the server are immune to deletion until they are unregistered.

registered_name: str | None = None
rpeel(delimiter: bytes | arkouda.numpy.dtypes.str_scalars, times: arkouda.numpy.dtypes.int_scalars = 1, includeDelimiter: bool = False, keepPartial: bool = False, regex: bool = False) Tuple[Strings, Strings][source]

Peel off one or more delimited fields from the end of each string (similar to string.rpartition), returning two new arrays of strings. Warning: This function is experimental and not guaranteed to work.

Parameters:
  • delimiter (bytes or str_scalars) – The separator where the split will occur

  • times (int_scalars, default=1) – The number of times the delimiter is sought, i.e. skip over the last (times-1) delimiters

  • includeDelimiter (bool, default=False) – If true, prepend the delimiter to the start of the first return array. By default, it is appended to the end of the second return array.

  • keepPartial (bool, default=False) – If true, a string that does not contain <times> instances of the delimiter will be returned in the second array. By default, such strings are returned in the first array.

  • regex (bool, default=False) – Indicates whether delimiter is a regular expression Note: only handles regular expressions supported by re2 (does not support lookaheads/lookbehinds)

Returns:

left: Strings

The remainder of the string after peeling

right: Strings

The field(s) that were peeled from the right of each string

Return type:

Tuple[Strings, Strings]

Raises:
  • TypeError – Raised if the delimiter parameter is not bytes or str_scalars or if times is not int64

  • ValueError – Raised if times is < 1 or if delimiter is not a valid regex

  • RuntimeError – Raised if there is a server-side error thrown

See also

peel, stick, lstick

Examples

>>> import arkouda as ak
>>> s = ak.array(['a.b', 'c.d', 'e.f.g'])
>>> s.rpeel('.')
(array(['a', 'c', 'e.f']), array(['b', 'd', 'g']))

Compared against peel

>>> s.peel('.')
(array(['a', 'c', 'e']), array(['b', 'd', 'f.g']))
search(pattern: bytes | arkouda.numpy.dtypes.str_scalars) arkouda.pandas.match.Match[source]

Return a match object with the first location in each element where pattern produces a match. Elements match if any part of the string matches the regular expression pattern.

Parameters:

pattern (bytes or str_scalars) – Regex used to find matches

Returns:

Match object where elements match if any part of the string matches the regular expression pattern

Return type:

Match

Examples

>>> import arkouda as ak
>>> strings = ak.array(['1_2___', '____', '3', '__4___5____6___7', ''])
>>> strings.search('_+')
<ak.Match object: matched=True, span=(1, 2); matched=True, span=(0, 4);
matched=False; matched=True, span=(0, 2); matched=False>
shape: Tuple[int]
size: arkouda.numpy.dtypes.int_scalars
split(delimiter: str, return_segments: bool = False, regex: bool = False) Strings | Tuple[source]

Unpack delimiter-joined substrings into a flat array.

Parameters:
  • delimiter (str) – Characters used to split strings into substrings

  • return_segments (bool, default=False) – If True, also return mapping of original strings to first substring in return array.

  • regex (bool, default=False) – Indicates whether delimiter is a regular expression Note: only handles regular expressions supported by re2 (does not support lookaheads/lookbehinds)

Returns:

Strings

Flattened substrings with delimiters removed

pdarray, int64 (optional)

For each original string, the index of first corresponding substring in the return array

Return type:

Union[Strings, Tuple]

See also

peel, rpeel

Examples

>>> import arkouda as ak
>>> orig = ak.array(['one|two', 'three|four|five', 'six'])
>>> orig.split('|')
array(['one', 'two', 'three', 'four', 'five', 'six'])
>>> flat, mapping = orig.split('|', return_segments=True)
>>> mapping
array([0 2 5])
>>> under = ak.array(['one_two', 'three_____four____five', 'six'])
>>> under_split, under_map = under.split('_+', return_segments=True, regex=True)
>>> under_split
array(['one', 'two', 'three', 'four', 'five', 'six'])
>>> under_map
array([0 2 5])
startswith(substr: bytes | arkouda.numpy.dtypes.str_scalars, regex: bool = False) arkouda.numpy.pdarrayclass.pdarray[source]

Check whether each element starts with the given substring.

Parameters:
  • substr (bytes or str_scalars) – The prefix to search for

  • regex (bool, default=False) – Indicates whether substr is a regular expression Note: only handles regular expressions supported by re2 (does not support lookaheads/lookbehinds)

Returns:

True for elements that start with substr, False otherwise

Return type:

pdarray

Raises:
  • TypeError – Raised if the substr parameter is not a bytes ior str_scalars

  • ValueError – Rasied if substr is not a valid regex

  • RuntimeError – Raised if there is a server-side error thrown

Examples

>>> import arkouda as ak
>>> strings_end = ak.array([f'string {i}' for i in range(1, 6)])
>>> strings_end
array(['string 1', 'string 2', 'string 3', 'string 4', 'string 5'])
>>> strings_end.startswith('string')
array([True True True True True])
>>> strings_start = ak.array([f'{i} string' for i in range(1,6)])
>>> strings_start
array(['1 string', '2 string', '3 string', '4 string', '5 string'])
>>> strings_start.startswith('\\d str', regex = True)
array([True True True True True])
stick(other: Strings, delimiter: bytes | arkouda.numpy.dtypes.str_scalars = '', toLeft: bool = False) Strings[source]

Join the strings from another array onto one end of the strings of this array, optionally inserting a delimiter. Warning: This function is experimental and not guaranteed to work.

Parameters:
  • other (Strings) – The strings to join onto self’s strings

  • delimiter (bytes or str_scalars, default="") – String inserted between self and other

  • toLeft (bool, default=False) – If true, join other strings to the left of self. By default, other is joined to the right of self.

Returns:

The array of joined strings

Return type:

Strings

Raises:
  • TypeError – Raised if the delimiter parameter is not bytes or str_scalars or if the other parameter is not a Strings instance

  • ValueError – Raised if times is < 1

  • RuntimeError – Raised if there is a server-side error thrown

See also

lstick, peel, rpeel

Examples

>>> import arkouda as ak
>>> s = ak.array(['a', 'c', 'e'])
>>> t = ak.array(['b', 'd', 'f'])
>>> s.stick(t, delimiter='.')
array(['a.b', 'c.d', 'e.f'])
strip(chars: bytes | arkouda.numpy.dtypes.str_scalars | None = '') Strings[source]

Return a new Strings object with all leading and trailing occurrences of characters contained in chars removed. The chars argument is a string specifying the set of characters to be removed. If omitted, the chars argument defaults to removing whitespace. The chars argument is not a prefix or suffix; rather, all combinations of its values are stripped.

Parameters:

chars (bytes or str_scalars, optional) – the set of characters to be removed

Returns:

Strings object with the leading and trailing characters matching the set of characters in the chars argument removed

Return type:

Strings

Raises:

RuntimeError – Raised if there is a server-side error thrown

Examples

>>> import arkouda as ak
>>> strings = ak.array(['Strings ', '  StringS  ', 'StringS   '])
>>> s = strings.strip()
>>> s
array(['Strings', 'StringS', 'StringS'])
>>> strings = ak.array(['Strings 1', '1 StringS  ', '  1StringS  12 '])
>>> s = strings.strip(' 12')
>>> s
array(['Strings', 'StringS', 'StringS'])
sub(pattern: bytes | arkouda.numpy.dtypes.str_scalars, repl: bytes | arkouda.numpy.dtypes.str_scalars, count: int = 0) Strings[source]

Return new Strings obtained by replacing non-overlapping occurrences of pattern with the replacement repl.

If count is nonzero, at most count substitutions occur.

Parameters:
  • pattern (bytes or str_scalars) – The regex to substitue

  • repl (bytes or str_scalars) – The substring to replace pattern matches with

  • count (int, default=0) – The max number of pattern match occurences in each element to replace. The default count=0 replaces all occurences of pattern with repl

Returns:

Strings with pattern matches replaced

Return type:

Strings

Raises:
  • TypeError – Raised if pattern or repl are not bytes or str_scalars

  • ValueError – Raised if pattern is not a valid regex

  • RuntimeError – Raised if there is a server-side error thrown

See also

Strings.subn

Examples

>>> import arkouda as ak
>>> strings = ak.array(['1_2___', '____', '3', '__4___5____6___7', ''])
>>> strings.sub(pattern='_+', repl='-', count=2)
array(['1-2-', '-', '3', '-4-5____6___7', ''])
subn(pattern: bytes | arkouda.numpy.dtypes.str_scalars, repl: bytes | arkouda.numpy.dtypes.str_scalars, count: int = 0) Tuple[Strings, arkouda.numpy.pdarrayclass.pdarray][source]

Perform the same operation as sub(), but return a tuple (new_Strings, number_of_substitions).

Parameters:
  • pattern (bytes or str_scalars) – The regex to substitue

  • repl (bytes or str_scalars) – The substring to replace pattern matches with

  • count (int, default=0) – The max number of pattern match occurences in each element to replace. The default count=0 replaces all occurences of pattern with repl

Returns:

Strings

Strings with pattern matches replaced

pdarray, int64

The number of substitutions made for each element of Strings

Return type:

Tuple[Strings, pdarray]

Raises:
  • TypeError – Raised if pattern or repl are not bytes or str_scalars

  • ValueError – Raised if pattern is not a valid regex

  • RuntimeError – Raised if there is a server-side error thrown

See also

Strings.sub

Examples

>>> import arkouda as ak
>>> strings = ak.array(['1_2___', '____', '3', '__4___5____6___7', ''])
>>> strings.subn(pattern='_+', repl='-', count=2)
(array(['1-2-', '-', '3', '-4-5____6___7', '']), array([2 1 0 2 0]))
take(indices: arkouda.numpy.dtypes.numeric_scalars | arkouda.numpy.pdarrayclass.pdarray, axis: int | None = None) Strings[source]

Take elements from the array along an axis.

When axis is not None, this function does the same thing as “fancy” indexing (indexing arrays using arrays); however, it can be easier to use if you need elements along a given axis. A call such as np.take(arr, indices, axis=3) is equivalent to arr[:,:,:,indices,...].

Parameters:
  • indices (numeric_scalars or pdarray) – The indices of the values to extract. Also allow scalars for indices.

  • axis (int, optional) – The axis over which to select values. By default, the flattened input array is used.

Returns:

A Strings containing the selected elements.

Return type:

Strings

Examples

>>> import arkouda as ak
>>> a = ak.array(["a","b","c"])
>>> indices = [0, 1]
>>> a.take(indices)
array(['a', 'b'])
title() Strings[source]

Return a new Strings from the original replaced with their titlecase equivalent.

Returns:

Strings from the original replaced with their titlecase equivalent.

Return type:

Strings

Raises:

RuntimeError – Raised if there is a server-side error thrown.

See also

Strings.lower, String.upper

Examples

>>> import arkouda as ak
>>> strings = ak.array([f'StrINgS {i}' for i in range(5)])
>>> strings
array(['StrINgS 0', 'StrINgS 1', 'StrINgS 2', 'StrINgS 3', 'StrINgS 4'])
>>> strings.title()
array(['Strings 0', 'Strings 1', 'Strings 2', 'Strings 3', 'Strings 4'])
to_csv(prefix_path: str, dataset: str = 'strings_array', col_delim: str = ',', overwrite: bool = False) str[source]

Write Strings to CSV file(s). File will contain a single column with the Strings data. All CSV Files written by Arkouda include a header denoting data types of the columns. Unlike other file formats, CSV files store Strings as their UTF-8 format instead of storing bytes as uint(8).

Parameters:
  • prefix_path (str) – The filename prefix to be used for saving files. Files will have _LOCALE#### appended when they are written to disk.

  • dataset (str, default="strings_array") – Column name to save the Strings under. Defaults to “strings_array”.

  • col_delim (str, default=",") – Defaults to “,”. Value to be used to separate columns within the file. Please be sure that the value used DOES NOT appear in your dataset.

  • overwrite (bool, default=False) – Defaults to False. If True, any existing files matching your provided prefix_path will be overwritten. If False, an error will be returned if existing files are found.

Returns:

response message

Return type:

str

Raises:
  • ValueError – Raised if all datasets are not present in all parquet files or if one or more of the specified files do not exist

  • RuntimeError – Raised if one or more of the specified files cannot be opened. If allow_errors is true this may be raised if no values are returned from the server.

  • TypeError – Raised if we receive an unknown arkouda_type returned from the server

Notes

  • CSV format is not currently supported by load/load_all operations

  • The column delimiter is expected to be the same for column names and data

  • Be sure that column delimiters are not found within your data.

  • All CSV files must delimit rows using newline (\\n) at this time.

to_hdf(prefix_path: str, dataset: str = 'strings_array', mode: Literal['truncate', 'append'] = 'truncate', save_offsets: bool = True, file_type: Literal['single', 'distribute'] = 'distribute') str[source]

Save the Strings object to HDF5. The object can be saved to a collection of files or single file.

Parameters:
  • prefix_path (str) – Directory and filename prefix that all output files share

  • dataset (str, default="strings_array") – The name of the Strings dataset to be written, defaults to strings_array

  • mode ({"truncate", "append"}, default = "truncate") – By default, truncate (overwrite) output files, if they exist. If ‘append’, create a new Strings dataset within existing files.

  • save_offsets (bool, default=True) – Defaults to True which will instruct the server to save the offsets array to HDF5 If False the offsets array will not be save and will be derived from the string values upon load/read.

  • file_type ({"single", "distribute"}, default = "distribute") – Default: Distribute Distribute the dataset over a file per locale. Single file will save the dataset to one file

Returns:

String message indicating result of save operation

Return type:

str

Raises:

RuntimeError – Raised if a server-side error is thrown saving the pdarray

Notes

  • Parquet files do not store the segments, only the values.

  • Strings state is saved as two datasets within an hdf5 group: one for the string characters and one for the segments corresponding to the start of each string

  • the hdf5 group is named via the dataset parameter.

  • The prefix_path must be visible to the arkouda server and the user must have write permission.

  • Output files have names of the form <prefix_path>_LOCALE<i>, where <i> ranges from 0 to numLocales for file_type=’distribute’. Otherwise, the file name will be prefix_path.

  • If any of the output files already exist and the mode is ‘truncate’, they will be overwritten. If the mode is ‘append’ and the number of output files is less than the number of locales or a dataset with the same name already exists, a RuntimeError will result.

  • Any file extension can be used.The file I/O does not rely on the extension to determine the file format.

See also

to_hdf

to_ndarray() numpy.ndarray[source]

Convert the array to a np.ndarray, transferring array data from the arkouda server to Python. If the array exceeds a built-in size limit, a RuntimeError is raised.

Returns:

A numpy ndarray with the same strings as this array

Return type:

np.ndarray

Notes

The number of bytes in the array cannot exceed ak.client.maxTransferBytes, otherwise a RuntimeError will be raised. This is to protect the user from overflowing the memory of the system on which the Python client is running, under the assumption that the server is running on a distributed system with much more memory than the client. The user may override this limit by setting ak.client.maxTransferBytes to a larger value, but proceed with caution.

See also

array, tolist

Examples

>>> import arkouda as ak
>>> a = ak.array(["hello", "my", "world"])
>>> a.to_ndarray()
array(['hello', 'my', 'world'], dtype='<U5')
>>> type(a.to_ndarray())
<class 'numpy.ndarray'>
to_parquet(prefix_path: str, dataset: str = 'strings_array', mode: Literal['truncate', 'append'] = 'truncate', compression: Literal['snappy', 'gzip', 'brotli', 'zstd', 'lz4'] | None = None) str[source]

Save the Strings object to Parquet. The result is a collection of files, one file per locale of the arkouda server, where each filename starts with prefix_path. Each locale saves its chunk of the array to its corresponding file.

Parameters:
  • prefix_path (str) – Directory and filename prefix that all output files share

  • dataset (str, default="strings_array") – Name of the dataset to create in files (must not already exist)

  • mode ({"truncate", "append"}, default = "truncate") – By default, truncate (overwrite) output files, if they exist. If ‘append’, attempt to create new dataset in existing files.

  • compression ({"snappy", "gzip", "brotli", "zstd", "lz4"}, optional) – Sets the compression type used with Parquet files

Returns:

string message indicating result of save operation

Return type:

str

Raises:

RuntimeError – Raised if a server-side error is thrown saving the pdarray

Notes

  • The prefix_path must be visible to the arkouda server and the user must

have write permission. - Output files have names of the form <prefix_path>_LOCALE<i>, where <i> ranges from 0 to numLocales for file_type=’distribute’. - ‘append’ write mode is supported, but is not efficient. - If any of the output files already exist and the mode is ‘truncate’, they will be overwritten. If the mode is ‘append’ and the number of output files is less than the number of locales or a dataset with the same name already exists, a RuntimeError will result. - Any file extension can be used.The file I/O does not rely on the extension to determine the file format.

tolist() List[str][source]

Convert the SegString to a list, transferring data from the arkouda server to Python. If the SegString exceeds a built-in size limit, a RuntimeError is raised.

Returns:

A list with the same strings as this SegString

Return type:

List[str]

Notes

The number of bytes in the array cannot exceed ak.client.maxTransferBytes, otherwise a RuntimeError will be raised. This is to protect the user from overflowing the memory of the system on which the Python client is running, under the assumption that the server is running on a distributed system with much more memory than the client. The user may override this limit by setting ak.client.maxTransferBytes to a larger value, but proceed with caution.

See also

to_ndarray

Examples

>>> import arkouda as ak
>>> a = ak.array(["hello", "my", "world"])
>>> a.tolist()
['hello', 'my', 'world']
>>> type(a.tolist())
<class 'list'>
transfer(hostname: str, port: arkouda.numpy.dtypes.int_scalars) str | memoryview[source]

Send a Strings object to a different Arkouda server.

Parameters:
  • hostname (str) – The hostname where the Arkouda server intended to receive the Strings object is running.

  • port (int_scalars) – The port to send the array over. This needs to be an open port (i.e., not one that the Arkouda server is running on). This will open up numLocales ports, each of which in succession, so will use ports of the range {port..(port+numLocales)} (e.g., running an Arkouda server of 4 nodes, port 1234 is passed as port, Arkouda will use ports 1234, 1235, 1236, and 1237 to send the array data). This port much match the port passed to the call to ak.receive_array().

Returns:

A message indicating a complete transfer

Return type:

str

Raises:
  • ValueError – Raised if the op is not within the pdarray.BinOps set

  • TypeError – Raised if other is not a pdarray or the pdarray.dtype is not a supported dtype

unregister() None[source]

Unregister a Strings object in the arkouda server which was previously registered using register() and/or attached to using attach().

Raises:

RuntimeError – Raised if the server could not find the internal name/symbol to remove

See also

register, attach

Notes

Registered names/Strings objects in the server are immune to deletion until they are unregistered.

update_hdf(prefix_path: str, dataset: str = 'strings_array', save_offsets: bool = True, repack: bool = True) str[source]

Overwrite the dataset with the name provided with this Strings object.

If the dataset does not exist it is added.

Parameters:
  • prefix_path (str) – Directory and filename prefix that all output files share

  • dataset (str, default="strings_array") – Name of the dataset to create in files

  • save_offsets (bool, default=True) – Defaults to True which will instruct the server to save the offsets array to HDF5 If False the offsets array will not be save and will be derived from the string values upon load/read.

  • repack (bool, default=True) – Default: True HDF5 does not release memory on delete. When True, the inaccessible data (that was overwritten) is removed. When False, the data remains, but is inaccessible. Setting to false will yield better performance, but will cause file sizes to expand.

Returns:

success message if successful

Return type:

str

Raises:

RuntimeError – Raised if a server-side error is thrown saving the Strings object

Notes

  • If file does not contain File_Format attribute to indicate how it was saved, the file name is checked for _LOCALE#### to determine if it is distributed.

  • If the dataset provided does not exist, it will be added

upper() Strings[source]

Return a new Strings with all lowercase characters from the original replaced with their uppercase equivalent.

Returns:

Strings with all lowercase characters from the original replaced with their uppercase equivalent

Return type:

Strings

Raises:

RuntimeError – Raised if there is a server-side error thrown

See also

Strings.lower

Examples

>>> import arkouda as ak
>>> strings = ak.array([f'StrINgS {i}' for i in range(5)])
>>> strings
array(['StrINgS 0', 'StrINgS 1', 'StrINgS 2', 'StrINgS 3', 'StrINgS 4'])
>>> strings.upper()
array(['STRINGS 0', 'STRINGS 1', 'STRINGS 2', 'STRINGS 3', 'STRINGS 4'])
class arkouda.numpy.TimeDelta64DType

Bases: numpy.dtype

DType class corresponding to the scalar type and dtype of the same name.

Please see numpy.dtype for the typical way to create dtype instances and arrays.dtypes for additional information.

class arkouda.numpy.Timedelta(pda, unit: str = _BASE_UNIT)[source]

Bases: _AbstractBaseTime

Represents a duration, the difference between two dates or times.

Timedelta is the Arkouda equivalent of pandas.TimedeltaIndex.

Parameters:
  • pda (int64 pdarray, pd.TimedeltaIndex, pd.Series, or np.timedelta64 array)

  • unit (str, default 'ns') –

    For int64 pdarray, denotes the unit of the input. Ignored for pandas and numpy arrays, which carry their own unit. Not case-sensitive; prefixes of full names (like ‘sec’) are accepted.

    Possible values:

    • ’weeks’ or ‘w’

    • ’days’ or ‘d’

    • ’hours’ or ‘h’

    • ’minutes’, ‘m’, or ‘t’

    • ’seconds’ or ‘s’

    • ’milliseconds’, ‘ms’, or ‘l’

    • ’microseconds’, ‘us’, or ‘u’

    • ’nanoseconds’, ‘ns’, or ‘n’

    Unlike in pandas, units cannot be combined or mixed with integers

Notes

The .values attribute is always in nanoseconds with int64 dtype.

abs()[source]

Absolute value of time interval.

property components
property days
is_registered() numpy.bool_[source]

Return True iff the object is contained in the registry or is a component of a registered object.

Returns:

Indicates if the object is contained in the registry

Return type:

numpy.bool

Raises:

RegistrationError – Raised if there’s a server-side error or a mis-match of registered components

Notes

Objects registered with the server are immune to deletion until they are unregistered.

property microseconds
property nanoseconds
register(user_defined_name)[source]

Register this Timedelta object and underlying components with the Arkouda server.

Parameters:

user_defined_name (str) – user defined name the timedelta is to be registered under, this will be the root name for underlying components

Returns:

The same Timedelta which is now registered with the arkouda server and has an updated name. This is an in-place modification, the original is returned to support a fluid programming style. Please note you cannot register two different Timedeltas with the same name.

Return type:

Timedelta

Raises:
  • TypeError – Raised if user_defined_name is not a str

  • RegistrationError – If the server was unable to register the timedelta with the user_defined_name

Notes

Objects registered with the server are immune to deletion until they are unregistered.

property seconds
special_objType = 'Timedelta'
std(ddof: arkouda.numpy.dtypes.int_scalars = 0, axis: None | int | tuple | None = None, keepdims: bool | None = False)[source]

Returns the standard deviation as a pd.Timedelta object, with args compatible with ak.std.

sum()[source]

Return sum of array elements along the given axis.

Parameters:
  • axis (int, Tuple[int, ...], optional, default = None) – The axis or axes along which to do the operation If None, the computation is done across the entire array.

  • keepdims (bool, optional, default = False) – Whether to keep the singleton dimension(s) along axis in the result.

Returns:

numeric_scalars if axis is omitted, in which case operation is done over entire array pdarray if axis is supplied, in which case the operation is done along that axis

Return type:

numeric_scalars or pdarray

Raises:
  • TypeError – Raised if pda is not a pdarray instance

  • RuntimeError – Raised if there’s a server-side error thrown

Examples

>>> import arkouda as ak
>>> ak.sum(ak.array([1,2,3,4,5]))
np.int64(15)
>>> ak.sum(ak.array([5.5,4.5,3.5,2.5,1.5]))
np.float64(17.5)
>>> ak.array([[1,2,3],[5,4,3]]).sum(axis=1)
array([6 12])

Notes

Works as a method of a pdarray (e.g. a.sum()) or a standalone function (e.g. ak.sum(a))

supported_opeq
supported_with_datetime
supported_with_pdarray
supported_with_r_datetime
supported_with_r_pdarray
supported_with_r_timedelta
supported_with_timedelta
to_pandas()[source]

Convert array to a pandas TimedeltaIndex. Note: if the array size exceeds client.maxTransferBytes, a RuntimeError is raised.

See also

to_ndarray

total_seconds()[source]
unregister()[source]

Unregister this timedelta object in the arkouda server which was previously registered using register() and/or attached to using attach().

Raises:

RegistrationError – If the object is already unregistered or if there is a server error when attempting to unregister

Notes

Objects registered with the server are immune to deletion until they are unregistered.

class arkouda.numpy.True_

Bases: numpy.generic

Boolean type (True or False), stored as a byte.

Warning

The bool type is not a subclass of the int_ type (the bool is not even a number type). This is different than Python’s default implementation of bool as a sub-class of int.

Character code:

'?'

class arkouda.numpy.UByteDType

Bases: numpy.dtypes._IntegerAbstractDType

DType class corresponding to the scalar type and dtype of the same name.

Please see numpy.dtype for the typical way to create dtype instances and arrays.dtypes for additional information.

class arkouda.numpy.UInt16DType

Bases: numpy.dtypes._IntegerAbstractDType

DType class corresponding to the scalar type and dtype of the same name.

Please see numpy.dtype for the typical way to create dtype instances and arrays.dtypes for additional information.

class arkouda.numpy.UInt32DType

Bases: numpy.dtypes._IntegerAbstractDType

DType class corresponding to the scalar type and dtype of the same name.

Please see numpy.dtype for the typical way to create dtype instances and arrays.dtypes for additional information.

class arkouda.numpy.UInt64DType

Bases: numpy.dtypes._IntegerAbstractDType

DType class corresponding to the scalar type and dtype of the same name.

Please see numpy.dtype for the typical way to create dtype instances and arrays.dtypes for additional information.

class arkouda.numpy.UInt8DType

Bases: numpy.dtypes._IntegerAbstractDType

DType class corresponding to the scalar type and dtype of the same name.

Please see numpy.dtype for the typical way to create dtype instances and arrays.dtypes for additional information.

class arkouda.numpy.UIntDType

Bases: numpy.dtypes._IntegerAbstractDType

DType class corresponding to the scalar type and dtype of the same name.

Please see numpy.dtype for the typical way to create dtype instances and arrays.dtypes for additional information.

class arkouda.numpy.ULongDType

Bases: numpy.dtypes._IntegerAbstractDType

DType class corresponding to the scalar type and dtype of the same name.

Please see numpy.dtype for the typical way to create dtype instances and arrays.dtypes for additional information.

class arkouda.numpy.ULongLongDType

Bases: numpy.dtypes._IntegerAbstractDType

DType class corresponding to the scalar type and dtype of the same name.

Please see numpy.dtype for the typical way to create dtype instances and arrays.dtypes for additional information.

class arkouda.numpy.UShortDType

Bases: numpy.dtypes._IntegerAbstractDType

DType class corresponding to the scalar type and dtype of the same name.

Please see numpy.dtype for the typical way to create dtype instances and arrays.dtypes for additional information.

class arkouda.numpy.VoidDType

Bases: numpy.dtype

DType class corresponding to the scalar type and dtype of the same name.

Please see numpy.dtype for the typical way to create dtype instances and arrays.dtypes for additional information.

arkouda.numpy.abs(pda: arkouda.numpy.pdarrayclass.pdarray) arkouda.numpy.pdarrayclass.pdarray[source]

Return the element-wise absolute value of the array.

Parameters:

pda (pdarray)

Returns:

A pdarray containing absolute values of the input array elements

Return type:

pdarray

Raises:

TypeError – Raised if the parameter is not a pdarray

Examples

>>> import arkouda as ak
>>> ak.abs(ak.arange(-5,-1))
array([5 4 3 2])
>>> ak.abs(ak.linspace(-5,-1,5))
array([5.00000000... 4.00000000... 3.00000000...
2.00000000... 1.00000000...])
arkouda.numpy.align(*args)[source]

Map multiple arrays of sparse identifiers to a common 0-up index.

Parameters:

*args (pdarrays or sequences of pdarrays) – Arrays to map to dense index

Returns:

aligned – Arrays with values replaced by 0-up indices

Return type:

list of pdarrays

class arkouda.numpy.all_scalars

Bases: _NotIterable

Mixin to prevent iteration, without being compatible with Iterable.

That is, we could do:

def __iter__(self): raise TypeError()

But this would make users of this mixin duck type-compatible with collections.abc.Iterable - isinstance(foo, Iterable) would be True.

Luckily, we can instead prevent iteration by setting __iter__ to None, which is treated specially.

copy_with(params)
arkouda.numpy.allclose(a: pdarray, b: pdarray, rtol: float = 1e-05, atol: float = 1e-08, equal_nan: bool = False) bool[source]

Returns True if all elements of a and b are equal within a tolerance.

This function compares two arrays elementwise and returns True if they are equal within the tolerance defined by the parameters rtol and atol. The comparison uses the formula: absolute(a - b) <= (atol + rtol * absolute(b))

Parameters:
  • a (pdarray) – First array to compare.

  • b (pdarray) – Second array to compare.

  • rtol (float, optional) – Relative tolerance. Default is 1e-5.

  • atol (float, optional) – Absolute tolerance. Default is 1e-8.

  • equal_nan (bool, optional) – Whether to consider NaNs in corresponding positions as equal. Default is False.

Returns:

True if all elements are equal within the specified tolerance, False otherwise.

Return type:

bool

Raises:
  • TypeError – If either a or b is not a pdarray.

  • TypeError – If either array has dtype bigint, which is not supported.

  • ValueError – If a and b have different shapes.

Examples

>>> import arkouda as ak
>>> x = ak.array([1.0, 2.0, 3.0])
>>> y = ak.array([1.0, 2.00001, 2.99999])
>>> ak.allclose(x, y)
True
arkouda.numpy.append(arr: arkouda.numpy.pdarrayclass.pdarray, values: arkouda.numpy.pdarrayclass.pdarray, axis: int | None = None) arkouda.numpy.pdarrayclass.pdarray[source]

Append values to the end of an array.

Parameters:
  • arr (pdarray) – Values are appended to a copy of this array.

  • values (pdarray) – These values are appended to a copy of arr. It must be of the correct shape (the same shape as arr, excluding axis). If axis is not specified, values can be any shape and will be flattened before use.

  • axis (Optional[int], default=None) – The axis along which values are appended. If axis is not given, both arr and values are flattened before use.

Returns:

A copy of arr with values appended to axis. Note that append does not occur in-place: a new array is allocated and filled. If axis is None, out is a flattened array.

Return type:

pdarray

See also

delete

Examples

>>> import arkouda as ak
>>> a = ak.array([1, 2, 3])
>>> b = ak.array([[4, 5, 6], [7, 8, 9]])
>>> ak.append(a, b)
array([1 2 3 4 5 6 7 8 9])
>>> ak.append(b, b, axis = 0)
array([array([4 5 6]) array([7 8 9]) array([4 5 6]) array([7 8 9])])
arkouda.numpy.arange(__arg1: arkouda.numpy.dtypes.int_scalars, *, dtype: numpy.dtype | type | arkouda.numpy.dtypes.bigint | None = None, max_bits: int | None = None) arkouda.numpy.pdarrayclass.pdarray[source]
arkouda.numpy.arange(__arg1: arkouda.numpy.dtypes.int_scalars, __arg2: arkouda.numpy.dtypes.int_scalars, *, dtype: numpy.dtype | type | arkouda.numpy.dtypes.bigint | None = None, max_bits: int | None = None) arkouda.numpy.pdarrayclass.pdarray
arkouda.numpy.arange(__arg1: arkouda.numpy.dtypes.int_scalars, __arg2: arkouda.numpy.dtypes.int_scalars, __arg3: arkouda.numpy.dtypes.int_scalars, *, dtype: numpy.dtype | type | arkouda.numpy.dtypes.bigint | None = None, max_bits: int | None = None) arkouda.numpy.pdarrayclass.pdarray

Create a pdarray of consecutive integers within the interval [start, stop).

Called as: arange([start,] stop[, step,] dtype=int64).

If only one arg is given then arg is the stop parameter. If two args are given, then the first arg is start and second is stop. If three args are given, then the first arg is start, second is stop, third is step.

The return value is cast to type dtype

Parameters:
  • start (int_scalars, optional)

  • stop (int_scalars, optional)

  • step (int_scalars, optional) – if one of these three is supplied, it’s used as stop, and start = 0, step = 1 if two of them are supplied, start = start, stop = stop, step = 1 if all three are supplied, start = start, stop = stop, step = step

  • dtype (np.dtype, type, or str) – The target dtype to cast values to

  • max_bits (int) – Specifies the maximum number of bits; only used for bigint pdarrays

Returns:

Integers from start (inclusive) to stop (exclusive) by step

Return type:

pdarray

Raises:
  • ValueError – Raised if none of start, stop, step was supplied

  • TypeError – Raised if start, stop, or step is not an int object

  • ZeroDivisionError – Raised if step == 0

See also

linspace, zeros, ones, randint

Notes

Negative steps result in decreasing values. Currently, only int64 pdarrays can be created with this method. For float64 arrays, use the linspace method.

Examples

>>> import arkouda as ak
>>> ak.arange(0, 5, 1)
array([0 1 2 3 4])
>>> ak.arange(5, 0, -1)
array([5 4 3 2 1])
>>> ak.arange(0, 10, 2)
array([0 2 4 6 8])
>>> ak.arange(-5, -10, -1)
array([-5 -6 -7 -8 -9])
arkouda.numpy.arccos(pda: arkouda.numpy.pdarrayclass.pdarray, where: bool | arkouda.numpy.pdarrayclass.pdarray = True) arkouda.numpy.pdarrayclass.pdarray[source]

Return the element-wise inverse cosine of the array. The result is between 0 and pi.

Parameters:
  • pda (pdarray)

  • where (bool or pdarray, default=True) – This condition is broadcast over the input. At locations where the condition is True, the inverse cosine will be applied to the corresponding value. Elsewhere, it will retain its original value. Default set to True.

Returns:

A pdarray containing inverse cosine for each element of the original pdarray

Return type:

pdarray

Raises:

TypeError – Raised if the parameter is not a pdarray

Examples

>>> import arkouda as ak
>>> a = ak.linspace(-0.7,0.5,4)
>>> ak.arccos(a)
array([2.34619382... 1.87548898... 1.47062890... 1.04719755...])
arkouda.numpy.arccosh(pda: arkouda.numpy.pdarrayclass.pdarray, where: bool | arkouda.numpy.pdarrayclass.pdarray = True) arkouda.numpy.pdarrayclass.pdarray[source]

Return the element-wise inverse hyperbolic cosine of the array.

Parameters:
  • pda (pdarray)

  • where (bool or pdarray, default=True) – This condition is broadcast over the input. At locations where the condition is True, the inverse hyperbolic cosine will be applied to the corresponding value. Elsewhere, it will retain its original value. Default set to True.

Returns:

A pdarray containing inverse hyperbolic cosine for each element of the original pdarray

Return type:

pdarray

Raises:

TypeError – Raised if the parameter is not a pdarray

Examples

>>> import arkouda as ak
>>> a = ak.linspace(1,500,4)
>>> ak.arccosh(a)
array([0.00000000... 5.81312608... 6.50328742... 6.90775427...])
arkouda.numpy.arcsin(pda: arkouda.numpy.pdarrayclass.pdarray, where: bool | arkouda.numpy.pdarrayclass.pdarray = True) arkouda.numpy.pdarrayclass.pdarray[source]

Return the element-wise inverse sine of the array. The result is between -pi/2 and pi/2.

Parameters:
  • pda (pdarray)

  • where (bool or pdarray, default=True) – This condition is broadcast over the input. At locations where the condition is True, the inverse sine will be applied to the corresponding value. Elsewhere, it will retain its original value. Default set to True.

Returns:

A pdarray containing inverse sine for each element of the original pdarray

Return type:

pdarray

Raises:

TypeError – Raised if the parameter is not a pdarray

Examples

>>> import arkouda as ak
>>> a = ak.linspace(-0.7,0.5,4)
>>> ak.arcsin(a)
array([-0.77539749... -0.30469265... 0.10016742... 0.52359877...])
arkouda.numpy.arcsinh(pda: arkouda.numpy.pdarrayclass.pdarray, where: bool | arkouda.numpy.pdarrayclass.pdarray = True) arkouda.numpy.pdarrayclass.pdarray[source]

Return the element-wise inverse hyperbolic sine of the array.

Parameters:
  • pda (pdarray)

  • where (bool or pdarray, default=True) – This condition is broadcast over the input. At locations where the condition is True, the inverse hyperbolic sine will be applied to the corresponding value. Elsewhere, it will retain its original value. Default set to True.

Returns:

A pdarray containing inverse hyperbolic sine for each element of the original pdarray

Return type:

pdarray

Raises:

TypeError – Raised if the parameter is not a pdarray

Examples

>>> import arkouda as ak
>>> a = ak.linspace(-500,500,4)
>>> ak.arcsinh(a)
array([-6.90775627... -5.80915199... 5.80915199... 6.90775627...])
arkouda.numpy.arctan(pda: arkouda.numpy.pdarrayclass.pdarray, where: bool | arkouda.numpy.pdarrayclass.pdarray = True) arkouda.numpy.pdarrayclass.pdarray[source]

Return the element-wise inverse tangent of the array. The result is between -pi/2 and pi/2.

Parameters:
  • pda (pdarray)

  • where (bool or pdarray, default=True) – This condition is broadcast over the input. At locations where the condition is True, the inverse tangent will be applied to the corresponding value. Elsewhere, it will retain its original value. Default set to True.

Returns:

A pdarray containing inverse tangent for each element of the original pdarray

Return type:

pdarray

Raises:

TypeError – Raised if the parameter is not a pdarray

Examples

>>> import arkouda as ak
>>> a = ak.linspace(-10.7,10.5,4)
>>> ak.arctan(a)
array([-1.47760906... -1.30221689... 1.28737507... 1.47584462...])
arkouda.numpy.arctan2(num: arkouda.numpy.pdarrayclass.pdarray | arkouda.numpy.dtypes.numeric_scalars, denom: arkouda.numpy.pdarrayclass.pdarray | arkouda.numpy.dtypes.numeric_scalars, where: bool | arkouda.numpy.pdarrayclass.pdarray = True) arkouda.numpy.pdarrayclass.pdarray[source]

Return the element-wise inverse tangent of the array pair. The result chosen is the signed angle in radians between the ray ending at the origin and passing through the point (1,0), and the ray ending at the origin and passing through the point (denom, num). The result is between -pi and pi.

Parameters:
  • num (pdarray or numeric_scalars) – Numerator of the arctan2 argument.

  • denom (pdarray or numeric_scalars) – Denominator of the arctan2 argument.

  • where (bool or pdarray, default=True) – This condition is broadcast over the input. At locations where the condition is True, the inverse tangent will be applied to the corresponding values. Elsewhere, it will retain its original value. Default set to True.

Returns:

A pdarray containing inverse tangent for each corresponding element pair of the original pdarray, using the signed values or the numerator and denominator to get proper placement on unit circle.

Return type:

pdarray

Raises:

TypeError

Raised if any parameter fails the typechecking
Raised if any element of pdarrays num and denom is not a supported type
Raised if both num and denom are scalars
Raised if where is neither boolean nor a pdarray of boolean

Examples

>>> import arkouda as ak
>>> x = ak.array([1,-1,-1,1])
>>> y = ak.array([1,1,-1,-1])
>>> ak.arctan2(y,x)
array([0.78539816... 2.35619449... -2.35619449... -0.78539816...])
arkouda.numpy.arctanh(pda: arkouda.numpy.pdarrayclass.pdarray, where: bool | arkouda.numpy.pdarrayclass.pdarray = True) arkouda.numpy.pdarrayclass.pdarray[source]

Return the element-wise inverse hyperbolic tangent of the array.

Parameters:
  • pda (pdarray)

  • where (bool or pdarray, default=True) – This condition is broadcast over the input. At locations where the condition is True, the inverse hyperbolic tangent will be applied to the corresponding value. Elsewhere, it will retain its original value. Default set to True.

Returns:

A pdarray containing inverse hyperbolic tangent for each element of the original pdarray

Return type:

pdarray

Raises:

TypeError – Raised if the parameters are not a pdarray or numeric scalar.

Examples

>>> import arkouda as ak
>>> a = ak.linspace(-.999,.999,4)
>>> ak.arctanh(a)
array([-3.80020116... -0.34619863... 0.34619863... 3.80020116...])
arkouda.numpy.argmaxk(pda: pdarray, k: arkouda.numpy.dtypes.int_scalars) pdarray[source]

Find the indices corresponding to the k maximum values of an array.

Returns the largest k values of an array, sorted

Parameters:
  • pda (pdarray) – Input array.

  • k (int_scalars) – The desired count of indices corresponding to maxmum array values

Returns:

The indices of the maximum k values from the pda, sorted

Return type:

pdarray

Raises:
  • TypeError – Raised if pda is not a pdarray or k is not an integer

  • ValueError – Raised if the pda is empty, or pda.ndim > 1, or k < 1

Notes

This call is equivalent in value to ak.argsort(a)[k:] and generally outperforms this operation.

This reduction will see a significant drop in performance as k grows beyond a certain value. This value is system dependent, but generally about a k of 5 million is where performance degradation has been observed.

Examples

>>> import arkouda as ak
>>> A = ak.array([10,5,1,3,7,2,9,0])
>>> ak.argmaxk(A, 3)
array([4 6 0])
>>> ak.argmaxk(A, 4)
array([1 4 6 0])
arkouda.numpy.argmink(pda: pdarray, k: arkouda.numpy.dtypes.int_scalars) pdarray[source]

Finds the indices corresponding to the k minimum values of an array.

Parameters:
  • pda (pdarray) – Input array.

  • k (int_scalars) – The desired count of indices corresponding to minimum array values

Returns:

The indices of the minimum k values from the pda, sorted

Return type:

pdarray

Raises:
  • TypeError – Raised if pda is not a pdarray or k is not an integer

  • ValueError – Raised if the pda is empty, or pda.ndim > 1, or k < 1

Notes

This call is equivalent in value to ak.argsort(a)[:k] and generally outperforms this operation.

This reduction will see a significant drop in performance as k grows beyond a certain value. This value is system dependent, but generally about a k of 5 million is where performance degradation has been observed.

Examples

>>> import arkouda as ak
>>> A = ak.array([10,5,1,3,7,2,9,0])
>>> ak.argmink(A, 3)
array([7 2 5])
>>> ak.argmink(A, 4)
array([7 2 5 3])
arkouda.numpy.argsort(pda: arkouda.numpy.pdarrayclass.pdarray | arkouda.numpy.strings.Strings | arkouda.pandas.categorical.Categorical, algorithm: SortingAlgorithm = SortingAlgorithm.RadixSortLSD, axis: arkouda.numpy.dtypes.int_scalars = 0, ascending: bool = True) arkouda.numpy.pdarrayclass.pdarray[source]

Return the permutation (indices) that sorts the array.

Parameters:
  • pda (pdarray, Strings, or Categorical) – The array to sort (supported: int64, uint64, float64 for pdarray).

  • algorithm (SortingAlgorithm, default SortingAlgorithm.RadixSortLSD) – The algorithm to use for sorting.

  • axis (int, default 0) – Axis to sort along. Negative values are normalized against the array rank. For 1D types (Strings, Categorical), must be 0.

  • ascending (bool, default True) – Sort order.

Returns:

Indices such that pda[indices] is sorted.

Return type:

pdarray

Raises:
  • TypeError – If pda is not a pdarray, Strings, or Categorical.

  • ValueError – If axis is out of bounds.

See also

coargsort

Notes

Uses a least-significant-digit radix sort, which is stable and resilient to non-uniformity in data but communication intensive.

Examples

>>> import arkouda as ak
>>> a = ak.randint(0, 10, 10, seed=1)
>>> a
array([7 9 5 1 4 1 8 5 5 0])
>>> perm = ak.argsort(a)
>>> a[perm]
array([0 1 1 4 5 5 5 7 8 9])
>>> ak.argsort(a, ak.sorting.SortingAlgorithm["RadixSortLSD"])
array([9 3 5 4 2 7 8 0 6 1])
>>> ak.argsort(a, ak.sorting.SortingAlgorithm["TwoArrayRadixSort"])
array([9 3 5 4 2 7 8 0 6 1])
>>> ak.argsort(a, ascending=False)
array([1 6 0 8 7 2 4 5 3 9])
arkouda.numpy.array(a: arkouda.numpy.pdarrayclass.pdarray | arkouda.numpy.strings.Strings | Iterable[Any] | numpy.typing.NDArray[Any], dtype: arkouda.numpy._typing._typing._StringDType = ..., *, copy: bool = ..., max_bits: int = ...) arkouda.numpy.strings.Strings[source]
arkouda.numpy.array(a: arkouda.numpy.pdarrayclass.pdarray | arkouda.numpy.strings.Strings | Iterable[Any] | numpy.typing.NDArray[Any], dtype: arkouda.numpy._typing._typing._NumericLikeDType = ..., *, copy: bool = ..., max_bits: int = ...) arkouda.numpy.pdarrayclass.pdarray
arkouda.numpy.array(a: arkouda.numpy.pdarrayclass.pdarray | arkouda.numpy.strings.Strings | Iterable[Any] | numpy.typing.NDArray[Any], dtype=None, *, copy: bool = ..., max_bits: int = ...) arkouda.numpy.pdarrayclass.pdarray | arkouda.numpy.strings.Strings
arkouda.numpy.array(a: arkouda.numpy.pdarrayclass.pdarray | List[arkouda.numpy._typing._typing._NumericLikeDType], dtype: arkouda.numpy._typing._typing._StringDType | arkouda.numpy._typing._typing._NumericLikeDType | None = None, copy: bool = False, max_bits: int = -1) arkouda.numpy.pdarrayclass.pdarray
arkouda.numpy.array(a: arkouda.numpy.strings.Strings | Iterable[arkouda.numpy._typing._typing._StringDType], dtype: arkouda.numpy._typing._typing._StringDType | arkouda.numpy._typing._typing._NumericLikeDType | None = None, copy: bool = False, max_bits: int = -1) arkouda.numpy.strings.Strings
arkouda.numpy.array(a: arkouda.numpy.pdarrayclass.pdarray | arkouda.numpy.strings.Strings | Iterable[Any] | numpy.typing.NDArray[Any], dtype: arkouda.numpy._typing._typing._StringDType | arkouda.numpy._typing._typing._NumericLikeDType | None = None, copy: bool = False, max_bits: int = -1) arkouda.numpy.pdarrayclass.pdarray | arkouda.numpy.strings.Strings

Convert a Python, NumPy, or Arkouda array-like into a pdarray or Strings object, transferring data to the Arkouda server.

Parameters:
  • a (Union[pdarray, np.ndarray, Iterable, Strings]) – The array-like input to convert. Supported types include Arkouda Strings, pdarray, NumPy ndarray, or Python iterables such as list, tuple, range, or deque.

  • dtype (Union[np.dtype, type, str], optional) – The target dtype to cast values to. This may be a NumPy dtype object, a NumPy scalar type (e.g. np.int64), or a string (e.g. ‘int64’, ‘str’).

  • copy (bool, default=False) – If True, a deep copy of the array is made. If False, no copy is made if the input is already a pdarray. Note: Arkouda does not currently support views or shallow copies. This differs from NumPy. Also, the default (False) is chosen to reduce performance overhead.

  • max_bits (int, optional) – The maximum number of bits for bigint arrays. Ignored for other dtypes.

Returns:

A pdarray stored on the Arkouda server, or a Strings object.

Return type:

Union[pdarray, Strings]

Raises:
  • TypeError

    • If a is not a pdarray, np.ndarray, or Python iterable.

    • If a is of string type and dtype is not ak.str_.

  • RuntimeError

    • If input size exceeds ak.client.maxTransferBytes.

    • If a.dtype is unsupported or incompatible with Arkouda.

    • If a.size * a.itemsize > maxTransferBytes.

  • ValueError

    • If a’s rank is not supported (see get_array_ranks()).

    • If the server response is malformed or missing required fields.

See also

pdarray.to_ndarray

Convert back from Arkouda to NumPy.

Notes

  • Arkouda does not currently support shallow copies or views; all copies are deep.

  • The number of bytes transferred to the server is limited by ak.client.maxTransferBytes. This prevents saturating the network during large transfers. To increase this limit, set ak.client.maxTransferBytes to a larger value manually.

  • If the input is a Unicode string array (dtype.kind == ‘U’ or dtype=’str’), this function recursively creates a Strings object from two internal `pdarray`s (one for offsets and one for concatenated string bytes).

Examples

>>> import arkouda as ak
>>> ak.array(np.arange(1, 10))
array([1 2 3 4 5 6 7 8 9])
>>> ak.array(range(1, 10))
array([1 2 3 4 5 6 7 8 9])
>>> strings = ak.array([f'string {i}' for i in range(5)])
>>> type(strings)
<class 'arkouda.numpy.strings.Strings'>
arkouda.numpy.array_equal(pda_a: arkouda.numpy.pdarrayclass.pdarray, pda_b: arkouda.numpy.pdarrayclass.pdarray, equal_nan: bool = False) bool[source]

Compares two pdarrays for equality. If neither array has any nan elements, then if all elements are pairwise equal, it returns True. If equal_Nan is False, then any nan element in either array gives a False return. If equal_Nan is True, then pairwise-corresponding nans are considered equal.

Parameters:
  • pda_a (pdarray)

  • pda_b (pdarray)

  • equal_nan (bool, default=False) – Determines how to handle nans

Returns:

With string data:

False if one array is type ak.str_ & the other isn’t, True if both are ak.str_ & they match.

With numeric data:

True if neither array has any nan elements, and all elements pairwise equal.

True if equal_Nan True, all non-nans pairwise equal & nans in pda_a correspond to nans in pda_b

False if equal_Nan False, & either array has any nan element.

Return type:

boolean

Examples

>>> import arkouda as ak
>>> a = ak.randint(0,10,10,dtype=ak.float64)
>>> b = a
>>> ak.array_equal(a,b)
True
>>> b[9] = np.nan
>>> ak.array_equal(a,b)
False
>>> a[9] = np.nan
>>> ak.array_equal(a,b)
False
>>> ak.array_equal(a,b,True)
True
arkouda.numpy.attach(name: str)[source]

Attach a previously created Arkouda object by its registered name.

This function retrieves an Arkouda object (e.g., pdarray, DataFrame, Series, etc.) associated with a given name. It returns the corresponding object based on the type of object stored under that name.

Parameters:

name (str) – The name of the object to attach.

Returns:

The Arkouda object associated with the given name. The returned object could be of any supported type, such as pdarray, DataFrame, Series, etc.

Return type:

object

Raises:

ValueError – If the object type in the response message does not match any known types.

Examples

>>> import arkouda as ak

Attach an existing pdarray >>> obj = ak.array([1, 2, 3]) >>> registered_obj = obj.register(“my_array”) >>> arr = ak.attach(“my_array”) >>> print(arr) [1 2 3] >>> registered_obj.unregister()

arkouda.numpy.attach_all(names: list)[source]

Attach to all objects registered with the provided names.

This function returns a dictionary mapping each name in the input list to the corresponding Arkouda object retrieved using attach.

Parameters:

names (List of str) – A list of names corresponding to registered Arkouda objects.

Returns:

A dictionary mapping each name to the attached Arkouda object.

Return type:

dict

Examples

>>> import arkouda as ak
>>> data = { "arr1": ak.array([0, 1, 2]), "arr2": ak.array([3, 4, 5]) }
>>> ak.register_all(data)

Assuming “arr1” and “arr2” were previously registered >>> attached_objs = ak.attach_all([“arr1”, “arr2”]) >>> print(attached_objs[“arr1”]) [0 1 2] >>> print(type(attached_objs[“arr2”])) <class ‘arkouda.numpy.pdarrayclass.pdarray’> >>> ak.unregister_all([“arr1”, “arr2”])

arkouda.numpy.base_repr(number, base=2, padding=0)

Return a string representation of a number in the given base system.

Parameters:
  • number (int) – The value to convert. Positive and negative values are handled.

  • base (int, optional) – Convert number to the base number system. The valid range is 2-36, the default value is 2.

  • padding (int, optional) – Number of zeros padded on the left. Default is 0 (no padding).

Returns:

out – String representation of number in base system.

Return type:

str

See also

binary_repr

Faster version of base_repr for base 2.

Examples

>>> import numpy as np
>>> np.base_repr(5)
'101'
>>> np.base_repr(6, 5)
'11'
>>> np.base_repr(7, base=5, padding=3)
'00012'
>>> np.base_repr(10, base=16)
'A'
>>> np.base_repr(32, base=16)
'20'
class arkouda.numpy.bigint[source]

Dtype sentinel for Arkouda’s variable-width (arbitrary-precision) integers.

This class represents the dtype object used by Arkouda arrays storing arbitrary-precision integers. It behaves similarly to NumPy’s dtype objects (such as np.int64), but corresponds to an unbounded, variable-width integer type. Instances of bigint are singletons created through __new__ so that all dtype references share the same object.

Construction semantics follow NumPy’s pattern: calling ak.bigint() returns the dtype sentinel, and calling ak.bigint(value) returns a bigint_ scalar constructed from value.

bigint instances compare equal to the bigint class, to themselves, to strings such as "bigint", and to other dtype-like objects whose name attribute equals "bigint". This allows interoperability across Arkouda’s dtype-resolution system.

Notes

This class represents only the dtype. Scalar values use bigint_, which inherits from int.

name

Canonical dtype name ("bigint").

Type:

str

kind

Dtype category code ("ui").

Type:

str

itemsize

Nominal bit-width (128). Actual precision is unbounded.

Type:

int

ndim

Number of dimensions for the dtype object (always 0).

Type:

int

shape

Empty tuple, following NumPy’s dtype API.

Type:

tuple

Examples

>>> import arkouda as ak
>>> ak.bigint()
dtype(bigint)
>>> ak.bigint(42)
ak.bigint_(42)
>>> dtype = ak.bigint()
>>> dtype.name
'bigint'
property is_signed: bool
property is_variable_width: bool
itemsize: int = 128
kind: str = 'ui'
name: str = 'bigint'
ndim: int = 0
shape: tuple = ()
type(x)[source]
class arkouda.numpy.bigint_[source]

Bases: int

Scalar type for Arkouda’s variable-width integer dtype.

bigint_ represents an individual arbitrary-precision integer value within Arkouda arrays that use the bigint dtype. It inherits directly from Python’s built-in int, ensuring full arbitrary-precision semantics while providing dtype metadata compatible with Arkouda.

This class is typically constructed indirectly via ak.bigint(value), which invokes the _BigIntMeta metaclass. Direct instantiation is also supported.

Construction

bigint_(x) converts x to an integer using Python’s int:

  • If x is str or bytes, it is interpreted using int(x, 0), allowing hexadecimal ("0xff"), binary ("0b1010"), and other literal forms.

  • Otherwise, x is passed directly to int(x).

Properties

dtypebigint

Returns the corresponding dtype sentinel, ak.bigint(). This mirrors NumPy scalar behavior (e.g., np.int64(1).dtype).

item()[source]

Return the underlying Python int value, matching NumPy scalar semantics.

Notes

bigint_ values behave exactly like Python int objects in arithmetic, hashing, comparison, and formatting. Arkouda arrays wrap and distribute many such scalars but do not impose fixed-width limits.

Examples

>>> import arkouda as ak
>>> x = ak.bigint(123)
>>> x
ak.bigint_(123)
>>> x + 10
133
>>> ak.bigint_("0xff")
ak.bigint_(255)
>>> x.dtype
dtype(bigint)
>>> x.item()
123
property dtype
item()[source]
arkouda.numpy.bigint_from_uint_arrays(arrays, max_bits=-1)[source]

Create a bigint pdarray from an iterable of uint pdarrays. The first item in arrays will be the highest 64 bits and the last item will be the lowest 64 bits.

Parameters:
  • arrays (Sequence[pdarray]) – An iterable of uint pdarrays used to construct the bigint pdarray. The first item in arrays will be the highest 64 bits and the last item will be the lowest 64 bits.

  • max_bits (int) – Specifies the maximum number of bits; only used for bigint pdarrays

Returns:

bigint pdarray constructed from uint arrays

Return type:

pdarray

Raises:
  • TypeError – Raised if any pdarray in arrays has a dtype other than uint or if the pdarrays are not the same size.

  • RuntimeError – Raised if there is a server-side error thrown

Examples

>>> import arkouda as ak
>>> a = ak.bigint_from_uint_arrays([ak.ones(5, dtype=ak.uint64), ak.arange(5, dtype=ak.uint64)])
>>> a
array([18446744073709551616 18446744073709551617 18446744073709551618
18446744073709551619 18446744073709551620])
>>> a.dtype
dtype(bigint)
>>> all(a[i] == 2**64 + i for i in range(5))
True
arkouda.numpy.binary_repr(num, width=None)

Return the binary representation of the input number as a string.

For negative numbers, if width is not given, a minus sign is added to the front. If width is given, the two’s complement of the number is returned, with respect to that width.

In a two’s-complement system negative numbers are represented by the two’s complement of the absolute value. This is the most common method of representing signed integers on computers [1]_. A N-bit two’s-complement system can represent every integer in the range \(-2^{N-1}\) to \(+2^{N-1}-1\).

Parameters:
  • num (int) – Only an integer decimal number can be used.

  • width (int, optional) – The length of the returned string if num is positive, or the length of the two’s complement if num is negative, provided that width is at least a sufficient number of bits for num to be represented in the designated form. If the width value is insufficient, an error is raised.

Returns:

bin – Binary representation of num or two’s complement of num.

Return type:

str

See also

base_repr

Return a string representation of a number in the given base system.

bin

Python’s built-in binary representation generator of an integer.

Notes

binary_repr is equivalent to using base_repr with base 2, but about 25x faster.

References

Examples

>>> import numpy as np
>>> np.binary_repr(3)
'11'
>>> np.binary_repr(-3)
'-11'
>>> np.binary_repr(3, width=4)
'0011'

The two’s complement is returned when the input number is negative and width is specified:

>>> np.binary_repr(-3, width=3)
'101'
>>> np.binary_repr(-3, width=5)
'11101'
class arkouda.numpy.bitType

Bases: numpy.unsignedinteger

Unsigned signed integer type, 64bit on 64bit systems and 32bit on 32bit

systems.

Character code:

'L'

Canonical name:

numpy.uint

Alias on this platform (Linux x86_64):

numpy.uint64: 64-bit unsigned integer (0 to 18_446_744_073_709_551_615).

Alias on this platform (Linux x86_64):

numpy.uintp: Unsigned integer large enough to fit pointer, compatible with C uintptr_t.

bit_count(/)

uint64.bit_count() -> int

Computes the number of 1-bits in the absolute value of the input. Analogous to the builtin int.bit_count or popcount in C++.

>>> np.uint64(127).bit_count()
7
class arkouda.numpy.bool

Bases: numpy.generic

Boolean type (True or False), stored as a byte.

Warning

The bool type is not a subclass of the int_ type (the bool is not even a number type). This is different than Python’s default implementation of bool as a sub-class of int.

Character code:

'?'

class arkouda.numpy.bool_scalars

Bases: _NotIterable

Mixin to prevent iteration, without being compatible with Iterable.

That is, we could do:

def __iter__(self): raise TypeError()

But this would make users of this mixin duck type-compatible with collections.abc.Iterable - isinstance(foo, Iterable) would be True.

Luckily, we can instead prevent iteration by setting __iter__ to None, which is treated specially.

copy_with(params)
arkouda.numpy.broadcast_arrays(*arrays: arkouda.numpy.pdarrayclass.pdarray) List[arkouda.numpy.pdarrayclass.pdarray][source]

Broadcast arrays to a common shape.

Parameters:

arrays (pdarray) – The arrays to broadcast. Must be broadcastable to a common shape.

Returns:

A list whose elements are the given Arrays broadcasted to the common shape.

Return type:

List

Raises:

ValueError – Raised by broadcast_to if a common shape cannot be determined.

Examples

>>> import arkouda as ak
>>> a = ak.arange(10).reshape(1,2,5)
>>> b = ak.arange(20).reshape(4,1,5)
>>> c = ak.broadcast_arrays(a,b)
>>> c[0][0,:,:]
array([array([0 1 2 3 4]) array([5 6 7 8 9])])
>>> c[1][:,0,0]
array([0 5 10 15])
arkouda.numpy.broadcast_dims(sa: Sequence[int], sb: Sequence[int]) Tuple[int, Ellipsis][source]

Determine the broadcasted shape of two arrays given their shapes.

This function implements the broadcasting rules from the Array API standard to compute the shape resulting from broadcasting two arrays together.

See: https://data-apis.org/array-api/latest/API_specification/broadcasting.html#algorithm

Parameters:
  • sa (Sequence[int]) – The shape of the first array.

  • sb (Sequence[int]) – The shape of the second array.

Returns:

The broadcasted shape resulting from combining sa and sb.

Return type:

Tuple[int, …]

Raises:

ValueError – If the shapes are not compatible for broadcasting.

Examples

>>> import arkouda as ak
>>> from arkouda.util import broadcast_dims
>>> broadcast_dims((5, 1), (1, 3))
(5, 3)
>>> broadcast_dims((4,), (3, 1))
(3, 4)
arkouda.numpy.broadcast_shapes(*shapes: Tuple[int, Ellipsis]) Tuple[int, Ellipsis][source]

Determine a broadcasted shape, given an arbitary number of shapes.

This function implements the broadcasting rules from the Array API standard to compute the shape resulting from broadcasting two arrays together.

See: https://data-apis.org/array-api/latest/API_specification/broadcasting.html#algorithm

Parameters:

shapes (Tuple[int, ...]) – a list or tuple of the shapes to be broadcast

Returns:

The broadcasted shape

Return type:

Tuple[int, …]

Raises:

ValueError – If the shapes are not compatible for broadcasting.

Examples

>>> import arkouda as ak
>>> ak.broadcast_shapes((1,2,3),(4,1,3),(4,2,1))
(4, 2, 3)
arkouda.numpy.broadcast_to(x: arkouda.numpy.dtypes.numeric_scalars | arkouda.numpy.pdarrayclass.pdarray, shape: int | Tuple[int, Ellipsis]) arkouda.numpy.pdarrayclass.pdarray[source]

Broadcast the array to the specified shape.

Parameters:
  • x (int, pdarray) – The int or array to be broadcast.

  • shape (int, Tuple[int, ...]) – The shape to which the array is to be broadcast.

Notes

If x and shape are both integers, the result has shape (shape,). If x is an int and shape is a tuple, the result has shape (shape,). if x is a pdarray and shape is an int, then if x.shape == (shape,)

x is unchanged. Otherwise a ValueError is raised.

If x is a pdarray and shape is a tuple, then x is broadcast to shape, if possible.

Returns:

A new array which is x broadcast to the provided shape.

Return type:

pdarray

Raises:

ValueError – Raised server-side if the broadcast fails, or client-side in the case where x is a pdarray, shape is an int, and x.shape != (shape,).

Examples

>>> import arkouda as ak
>>> a = ak.arange(5)
>>> ak.broadcast_to(a,(2,5))
array([array([0 1 2 3 4]) array([0 1 2 3 4])])
class arkouda.numpy.byte

Bases: numpy.signedinteger

Signed integer type, compatible with C char.

Character code:

'b'

Canonical name:

numpy.byte

Alias on this platform (Linux x86_64):

numpy.int8: 8-bit signed integer (-128 to 127).

bit_count(/)

int8.bit_count() -> int

Computes the number of 1-bits in the absolute value of the input. Analogous to the builtin int.bit_count or popcount in C++.

>>> np.int8(127).bit_count()
7
>>> np.int8(-127).bit_count()
7
class arkouda.numpy.bytes_

A byte string.

When used in arrays, this type strips trailing null bytes.

Character code:

'S'

T(*args, **kwargs)

Scalar attribute identical to the corresponding array attribute.

Please see ndarray.T.

all(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.all.

any(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.any.

argmax(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.argmax.

argmin(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.argmin.

argsort(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.argsort.

astype(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.astype.

base(*args, **kwargs)

Scalar attribute identical to the corresponding array attribute.

Please see ndarray.base.

byteswap(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.byteswap.

choose(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.choose.

clip(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.clip.

compress(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.compress.

conj(*args, **kwargs)
conjugate(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.conjugate.

copy(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.copy.

cumprod(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.cumprod.

cumsum(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.cumsum.

data(*args, **kwargs)

Pointer to start of data.

device(*args, **kwargs)
diagonal(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.diagonal.

dtype(*args, **kwargs)

Get array data-descriptor.

dump(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.dump.

dumps(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.dumps.

fill(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.fill.

flags(*args, **kwargs)

The integer value of flags.

flat(*args, **kwargs)

A 1-D view of the scalar.

flatten(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.flatten.

getfield(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.getfield.

imag(*args, **kwargs)

The imaginary part of the scalar.

item(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.item.

itemset(*args, **kwargs)
itemsize(*args, **kwargs)

The length of one element in bytes.

max(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.max.

mean(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.mean.

min(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.min.

nbytes(*args, **kwargs)
ndim(*args, **kwargs)

The number of array dimensions.

newbyteorder(*args, **kwargs)
nonzero(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.nonzero.

prod(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.prod.

ptp(*args, **kwargs)
put(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.put.

ravel(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.ravel.

real(*args, **kwargs)

The real part of the scalar.

repeat(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.repeat.

reshape(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.reshape.

resize(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.resize.

round(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.round.

searchsorted(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.searchsorted.

setfield(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.setfield.

setflags(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.setflags.

shape(*args, **kwargs)

Tuple of array dimensions.

size(*args, **kwargs)

The number of elements in the gentype.

sort(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.sort.

squeeze(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.squeeze.

std(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.std.

strides(*args, **kwargs)

Tuple of bytes steps in each dimension.

sum(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.sum.

swapaxes(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.swapaxes.

take(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.take.

to_device(*args, **kwargs)
tobytes(*args, **kwargs)
tofile(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.tofile.

tolist(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.tolist.

tostring(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.tostring.

trace(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.trace.

transpose(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.transpose.

var(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.var.

view(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.view.

arkouda.numpy.can_cast(from_dt, to_dt, casting: Literal['safe'] | None = 'safe') bool[source]

Determine whether a value of one dtype can be safely cast to another, following NumPy-like rules but including Arkouda-specific handling for bigint and bigint_.

The default "safe" mode uses the following logic:

  • bigintbigint: always allowed.

  • bigint → float dtypes: allowed (may lose precision, but magnitude fits).

  • bigint → fixed-width signed/unsigned integers: not allowed, due to potential overflow.

  • int64 / uint64 → bigint: allowed (widening).

  • float → bigint: not allowed (information loss).

  • All other cases fall back to numpy.can_cast semantics.

Parameters:
  • from_dt (Any) – Source dtype or scalar-like object.

  • to_dt (Any) – Target dtype or scalar-like object.

  • casting (str, optional) – Casting rule, matching NumPy’s can_cast API. Only "safe" is currently implemented. Other values are accepted for API compatibility but routed through the same logic.

Examples

>>> import arkouda as ak
>>> from arkouda.numpy import can_cast, dtype

# bigint → bigint >>> can_cast(dtype(“bigint”), dtype(“bigint”)) True

# bigint → float64 >>> can_cast(dtype(“bigint”), dtype(“float64”)) True

# bigint → int64 (unsafe) >>> can_cast(dtype(“bigint”), dtype(“int64”)) False

# int64 → bigint (widening) >>> can_cast(dtype(“int64”), dtype(“bigint”)) True

# float → bigint (lossy) >>> can_cast(dtype(“float64”), dtype(“bigint”)) False

# Standard NumPy cases >>> can_cast(dtype(“int64”), dtype(“float64”)) True >>> can_cast(dtype(“float64”), dtype(“int64”)) False

arkouda.numpy.cast(pda: arkouda.numpy.pdarrayclass.pdarray, dt: arkouda.numpy._typing.StringDTypeTypes, errors: Literal[ErrorMode, ErrorMode] = ErrorMode.strict) arkouda.numpy.strings.Strings[source]
arkouda.numpy.cast(pda: arkouda.numpy.pdarrayclass.pdarray, dt: arkouda.numpy._typing.NumericDTypeTypes, errors: Literal[ErrorMode, ErrorMode] = ErrorMode.strict) arkouda.numpy.pdarrayclass.pdarray
arkouda.numpy.cast(pda: arkouda.numpy.strings.Strings, dt: arkouda.numpy._typing.ArkoudaNumericTypes | arkouda.numpy._typing.BuiltinNumericTypes | numpy.dtype[Any] | arkouda.numpy.dtypes.bigint, errors: Literal[ErrorMode]) Tuple[arkouda.numpy.pdarrayclass.pdarray, arkouda.numpy.pdarrayclass.pdarray]
arkouda.numpy.cast(pda: arkouda.numpy.strings.Strings, dt: arkouda.numpy._typing.ArkoudaNumericTypes | arkouda.numpy._typing.BuiltinNumericTypes | numpy.dtype[Any] | arkouda.numpy.dtypes.bigint, errors: Literal[ErrorMode, ErrorMode] = ErrorMode.strict) arkouda.numpy.pdarrayclass.pdarray
arkouda.numpy.cast(pda: arkouda.numpy.strings.Strings, dt: arkouda.numpy._typing.StringDTypeTypes, errors: Literal[ErrorMode, ErrorMode] = ErrorMode.strict) arkouda.numpy.strings.Strings
arkouda.numpy.cast(pda: arkouda.numpy.strings.Strings, dt: type[arkouda.pandas.categorical.Categorical], errors: Literal[ErrorMode, ErrorMode] = ErrorMode.strict) arkouda.pandas.categorical.Categorical
arkouda.numpy.cast(pda: arkouda.pandas.categorical.Categorical, dt: arkouda.numpy._typing.StringDTypeTypes, errors: Literal[ErrorMode, ErrorMode] = ErrorMode.strict) arkouda.numpy.strings.Strings
arkouda.numpy.cast(pda: arkouda.numpy.pdarrayclass.pdarray | arkouda.numpy.dtypes.numeric_scalars, dt: arkouda.numpy._typing.ArkoudaNumericTypes | arkouda.numpy._typing.BuiltinNumericTypes | numpy.dtype[Any] | arkouda.numpy.dtypes.bigint | None, errors: Literal[ErrorMode, ErrorMode] = ErrorMode.strict) arkouda.numpy.pdarrayclass.pdarray
arkouda.numpy.cast(pda: arkouda.numpy.pdarrayclass.pdarray | arkouda.numpy.strings.Strings | arkouda.pandas.categorical.Categorical | arkouda.numpy.dtypes.numeric_scalars, dt: str, errors: Literal[ErrorMode, ErrorMode] = ErrorMode.strict) arkouda.numpy.pdarrayclass.pdarray | arkouda.numpy.strings.Strings | arkouda.pandas.categorical.Categorical

Cast an array to another dtype.

Parameters:
  • pda (pdarray, Strings, or Categorical) – The array of values to cast

  • dt (np.dtype, type, str, or bigint) – The target dtype to cast values to

  • errors ({strict, ignore, return_validity}, default=ErrorMode.strict) –

    Controls how errors are handled when casting strings to a numeric type (ignored for casts from numeric types).

    • strict: raise RuntimeError if any string cannot be converted

    • ignore: never raise an error. Uninterpretable strings get

      converted to NaN (float64), -2**63 (int64), zero (uint64 and uint8), or False (bool)

    • return_validity: in addition to returning the same output as “ignore”, also return a bool array indicating where the cast was successful.

    Default set to strict.

Returns:

pdarray or Strings

Array of values cast to desired dtype

[validitypdarray(bool)]

If errors=”return_validity” and input is Strings, a second array is returned with True where the cast succeeded and False where it failed.

Return type:

Union[Union[pdarray, Strings, Categorical], Tuple[pdarray, pdarray]]

Notes

The cast is performed according to Chapel’s casting rules and is NOT safe from overflows or underflows. The user must ensure that the target dtype has the precision and capacity to hold the desired result.

Examples

>>> import arkouda as ak
>>> ak.cast(ak.linspace(1.0,5.0,5), dt=ak.int64)
array([1 2 3 4 5])
>>> ak.cast(ak.arange(0,5), dt=ak.float64).dtype
dtype('float64')
>>> ak.cast(ak.arange(0,5), dt=ak.bool_)
array([False True True True True])
>>> ak.cast(ak.linspace(0,4,5), dt=ak.bool_)
array([False True True True True])
class arkouda.numpy.cdouble

Bases: numpy.complexfloating

Complex number type composed of two double-precision floating-point

numbers, compatible with Python complex.

Character code:

'D'

Canonical name:

numpy.cdouble

Alias on this platform (Linux x86_64):

numpy.complex128: Complex number type composed of 2 64-bit-precision floating-point numbers.

arkouda.numpy.ceil(pda: arkouda.numpy.pdarrayclass.pdarray, where: bool | arkouda.numpy.pdarrayclass.pdarray = True) arkouda.numpy.pdarrayclass.pdarray[source]

Return the element-wise ceiling of the array.

Parameters:
  • pda (pdarray)

  • where (bool or pdarray, default=True) – This condition is applied over the input. At locations where the condition is True, the corresponding value will be acted on by the function. Elsewhere, it will retain its original value. Default set to True.

Returns:

A pdarray containing ceiling values of the input array elements

Return type:

pdarray

Raises:

TypeError – Raised if the parameter is not a pdarray

Examples

>>> import arkouda as ak
>>> ak.ceil(ak.linspace(1.1,5.5,5))
array([2.00000000... 3.00000000... 4.00000000... 5.00000000... 6.00000000...])
arkouda.numpy.clear() None[source]

Send a clear message to clear all unregistered data from the server symbol table.

Raises:

RuntimeError – Raised if there is a server-side error in executing clear request

arkouda.numpy.clip(pda: arkouda.numpy.pdarrayclass.pdarray, lo: arkouda.numpy.dtypes.numeric_scalars | arkouda.numpy.pdarrayclass.pdarray, hi: arkouda.numpy.dtypes.numeric_scalars | arkouda.numpy.pdarrayclass.pdarray) arkouda.numpy.pdarrayclass.pdarray[source]

Clip (limit) the values in an array to a given range [lo,hi].

Given an array a, values outside the range are clipped to the range edges, such that all elements lie in the range.

There is no check to enforce that lo < hi. If lo > hi, the corresponding value of the array will be set to hi.

If lo or hi (or both) are pdarrays, the check is by pairwise elements. See examples.

Parameters:
  • pda (pdarray) – the array of values to clip

  • lo (numeric_scalars or pdarray) – the lower value of the clipping range

  • hi (numeric_scalars or pdarray) – the higher value of the clipping range If lo or hi (or both) are pdarrays, the check is by pairwise elements. See examples.

Returns:

A pdarray matching pda, except that element x remains x if lo <= x <= hi,

or becomes lo if x < lo, or becomes hi if x > hi.

Return type:

pdarray

Examples

>>> import arkouda as ak
>>> a = ak.array([1,2,3,4,5,6,7,8,9,10])
>>> ak.clip(a,3,8)
array([3 3 3 4 5 6 7 8 8 8])
>>> ak.clip(a,3,8.0)
array([3.00000000... 3.00000000... 3.00000000... 4.00000000...
       5.00000000... 6.00000000... 7.00000000... 8.00000000...
       8.00000000... 8.00000000...])
>>> ak.clip(a,None,7)
array([1 2 3 4 5 6 7 7 7 7])
>>> ak.clip(a,5,None)
array([5 5 5 5 5 6 7 8 9 10])
>>> ak.clip(a,None,None)
ValueError: Either min or max must be supplied.
>>> ak.clip(a,ak.array([2,2,3,3,8,8,5,5,6,6]),8)
array([2 2 3 4 8 8 7 8 8 8])
>>> ak.clip(a,4,ak.array([10,9,8,7,6,5,5,5,5,5]))
array([4 4 4 4 5 5 5 5 5 5])

Notes

Either lo or hi may be None, but not both. If lo > hi, all x = hi. If all inputs are int64, output is int64, but if any input is float64, output is float64.

Raises:

ValueError – Raised if both lo and hi are None

class arkouda.numpy.clongdouble

Bases: numpy.complexfloating

Complex number type composed of two extended-precision floating-point

numbers.

Character code:

'G'

Alias on this platform (Linux x86_64):

numpy.complex256: Complex number type composed of 2 128-bit extended-precision floating-point numbers.

arkouda.numpy.clz(pda: pdarray) pdarray[source]

Count leading zeros for each integer in an array.

Parameters:

pda (pdarray, int64, uint64, bigint) – Input array (must be integral).

Returns:

The number of leading zeros of each element.

Return type:

pdarray

Raises:

TypeError – If input array is not int64, uint64, or bigint

Examples

>>> import arkouda as ak
>>> A = ak.arange(10)
>>> ak.clz(A)
array([64 63 62 62 61 61 61 61 60 60])
arkouda.numpy.coargsort(arrays: Sequence[arkouda.numpy.strings.Strings | arkouda.numpy.pdarrayclass.pdarray | arkouda.pandas.categorical.Categorical], algorithm: SortingAlgorithm = SortingAlgorithm.RadixSortLSD, ascending: bool = True) arkouda.numpy.pdarrayclass.pdarray[source]

Return the permutation that groups the rows (left-to-right), if the input arrays are treated as columns. The permutation sorts numeric columns, but not Strings or Categoricals — those are grouped, not ordered.

Parameters:
  • arrays (Sequence of Strings, pdarray, or Categorical) – The columns (int64, uint64, float64, Strings, or Categorical) to sort by row.

  • algorithm (SortingAlgorithm, default=SortingAlgorithm.RadixSortLSD) – The algorithm to be used for sorting the arrays.

  • ascending (bool, default=True) – Whether to sort in ascending order. Ignored when arrays have ndim > 1.

Returns:

The indices that permute the rows into grouped order.

Return type:

pdarray

Raises:

ValueError – If the inputs are not all the same size or not valid array types.

See also

argsort

Notes

Uses a least-significant-digit radix sort, which is stable and resilient to non-uniformity in data but communication intensive. Starts with the last array and moves forward.

For Strings, sorting is based on a hash. This ensures grouping of identical strings, but not lexicographic order. For Categoricals, sorting is based on the internal codes.

Examples

>>> import arkouda as ak
>>> a = ak.array([0, 1, 0, 1])
>>> b = ak.array([1, 1, 0, 0])
>>> perm = ak.coargsort([a, b])
>>> perm
array([2 0 3 1])
>>> a[perm]
array([0 0 1 1])
>>> b[perm]
array([0 1 0 1])
class arkouda.numpy.complex128

Bases: numpy.complexfloating

Complex number type composed of two double-precision floating-point

numbers, compatible with Python complex.

Character code:

'D'

Canonical name:

numpy.cdouble

Alias on this platform (Linux x86_64):

numpy.complex128: Complex number type composed of 2 64-bit-precision floating-point numbers.

class arkouda.numpy.complex64

Bases: numpy.complexfloating

Complex number type composed of two single-precision floating-point

numbers.

Character code:

'F'

Canonical name:

numpy.csingle

Alias on this platform (Linux x86_64):

numpy.complex64: Complex number type composed of 2 32-bit-precision floating-point numbers.

arkouda.numpy.concatenate(arrays: Sequence[arkouda.numpy.pdarrayclass.pdarray | arkouda.numpy.strings.Strings | arkouda.pandas.categorical.Categorical], axis: int = 0, ordered: bool = True) arkouda.numpy.pdarrayclass.pdarray | arkouda.numpy.strings.Strings | arkouda.pandas.categorical.Categorical | Sequence[arkouda.pandas.categorical.Categorical][source]

Concatenate a list or tuple of pdarray or Strings objects into one pdarray or Strings object, respectively.

Parameters:
  • arrays (Sequence[Union[pdarray,Strings,Categorical]]) – The arrays to concatenate. Must all have same dtype.

  • axis (int, default = 0) – The axis along which the arrays will be joined. If axis is None, arrays are flattened before use. Only for use with pdarray, and when ordered is True. Default is 0.

  • ordered (bool) – If True (default), the arrays will be appended in the order given. If False, array data may be interleaved in blocks, which can greatly improve performance but results in non-deterministic ordering of elements.

Returns:

Single pdarray or Strings object containing all values, returned in the original order

Return type:

Union[pdarray,Strings,Categorical]

Raises:
  • ValueError – Raised if arrays is empty or if pdarrays have differing dtypes

  • TypeError – Raised if arrays is not a pdarrays or Strings python Sequence such as a list or tuple

  • RuntimeError – Raised if any array elements are dtypes for which concatenate has not been implemented.

Examples

>>> import arkouda as ak
>>> ak.concatenate([ak.array([1, 2, 3]), ak.array([4, 5, 6])])
array([1 2 3 4 5 6])
>>> ak.concatenate([ak.array([True,False,True]),ak.array([False,True,True])])
array([True False True False True True])
>>> ak.concatenate([ak.array(['one','two']),ak.array(['three','four','five'])])
array(['one', 'two', 'three', 'four', 'five'])
arkouda.numpy.copy(a: arkouda.numpy.strings.Strings | arkouda.numpy.pdarrayclass.pdarray) arkouda.numpy.strings.Strings | arkouda.numpy.pdarrayclass.pdarray[source]

Return a deep copy of the given Arkouda object.

Parameters:

a (Union[Strings, pdarray]) – The object to copy.

Returns:

A deep copy of the pdarray or Strings object.

Return type:

Union[Strings, pdarray]

Raises:

TypeError – If the input is not a Strings or pdarray instance.

arkouda.numpy.corr(x: pdarray, y: pdarray) numpy.float64[source]

Return the correlation between x and y.

Parameters:
  • x (pdarray) – One of the pdarrays used to calculate correlation

  • y (pdarray) – One of the pdarrays used to calculate correlation

Returns:

The scalar correlation of the two pdarrays

Return type:

np.float64

Examples

>>> import arkouda as ak
>>> a = ak.arange(10)
>>> b = a + 1
>>> ak.corr(a,b)
np.float64(0.9999999999999998)
>>> a.corr(b)
np.float64(0.9999999999999998)
Raises:
  • TypeError – Raised if x or y is not a pdarray instance

  • RuntimeError – Raised if there’s a server-side error thrown

See also

std, cov

Notes

The correlation is calculated by cov(x, y) / (x.std(ddof=1) * y.std(ddof=1))

arkouda.numpy.cos(pda: arkouda.numpy.pdarrayclass.pdarray, where: bool | arkouda.numpy.pdarrayclass.pdarray = True) arkouda.numpy.pdarrayclass.pdarray[source]

Return the element-wise cosine of the array.

Parameters:
  • pda (pdarray)

  • where (bool or pdarray, default=True) – This condition is broadcast over the input. At locations where the condition is True, the cosine will be applied to the corresponding value. Elsewhere, it will retain its original value. Default set to True.

Returns:

A pdarray containing cosine for each element of the original pdarray

Return type:

pdarray

Raises:

TypeError – Raised if the parameter is not a pdarray

Examples

>>> import arkouda as ak
>>> a = ak.linspace(-1.5,0.75,4)
>>> ak.cos(a)
array([0.07073720... 0.73168886... 1.00000000... 0.73168886...])
arkouda.numpy.cosh(pda: arkouda.numpy.pdarrayclass.pdarray, where: bool | arkouda.numpy.pdarrayclass.pdarray = True) arkouda.numpy.pdarrayclass.pdarray[source]

Return the element-wise hyperbolic cosine of the array.

Parameters:
  • pda (pdarray)

  • where (bool or pdarray, default=True) – This condition is broadcast over the input. At locations where the condition is True, the hyperbolic cosine will be applied to the corresponding value. Elsewhere, it will retain its original value. Default set to True.

Returns:

A pdarray containing hyperbolic cosine for each element of the original pdarray

Return type:

pdarray

Raises:

TypeError – Raised if the parameter is not a pdarray

Examples

>>> import arkouda as ak
>>> a = ak.linspace(-0.9,0.7,4)
>>> ak.cosh(a)
array([1.43308638... 1.06797874... 1.01392106... 1.25516900...])
arkouda.numpy.count_nonzero(pda: arkouda.numpy.pdarrayclass.pdarray) arkouda.numpy.dtypes.int_scalars[source]

Compute the nonzero count of a given array. 1D case only, for now.

Parameters:

pda (pdarray) – The input data, in pdarray form, numeric, bool, or str

Returns:

The nonzero count of the entire pdarray

Return type:

int_scalars

Raises:
  • TypeError – Raised if the parameter is not a pdarray with numeric, bool, or str datatype

  • ValueError – Raised if sum applied to the pdarray doesn’t come back with a scalar

Examples

>>> import arkouda as ak
>>> pda = ak.array([0,4,7,8,1,3,5,2,-1])
>>> ak.count_nonzero(pda)
np.int64(8)
>>> pda = ak.array([False,True,False,True,False])
>>> ak.count_nonzero(pda)
np.int64(2)
>>> pda = ak.array(["hello","","there"])
>>> ak.count_nonzero(pda)
np.int64(2)
arkouda.numpy.cov(x: pdarray, y: pdarray) numpy.float64[source]

Return the covariance of x and y.

Parameters:
  • x (pdarray) – One of the pdarrays used to calculate covariance

  • y (pdarray) – One of the pdarrays used to calculate covariance

Returns:

The scalar covariance of the two pdarrays

Return type:

np.float64

Examples

>>> import arkouda as ak
>>> a = ak.arange(10)
>>> b = a + 1
>>> ak.cov(a,b)
np.float64(9.166666666666666)
>>> a.cov(b)
np.float64(9.166666666666666)
Raises:
  • TypeError – Raised if x or y is not a pdarray instance

  • RuntimeError – Raised if there’s a server-side error thrown

See also

mean, var

Notes

The covariance is calculated by cov = ((x - x.mean()) * (y - y.mean())).sum() / (x.size - 1).

class arkouda.numpy.csingle

Bases: numpy.complexfloating

Complex number type composed of two single-precision floating-point

numbers.

Character code:

'F'

Canonical name:

numpy.csingle

Alias on this platform (Linux x86_64):

numpy.complex64: Complex number type composed of 2 32-bit-precision floating-point numbers.

arkouda.numpy.ctz(pda: pdarray) pdarray[source]

Count trailing zeros for each integer in an array.

Parameters:

pda (pdarray, int64, uint64, bigint) – Input array (must be integral).

Returns:

The number of trailing zeros of each element.

Return type:

pdarray

Notes

ctz(0) is defined to be zero.

Raises:

TypeError – If input array is not int64, uint64, or bigint

Examples

>>> import arkouda as ak
>>> A = ak.arange(10)
>>> ak.ctz(A)
array([0 0 1 0 2 0 1 0 3 0])
arkouda.numpy.cumprod(pda: arkouda.numpy.pdarrayclass.pdarray, axis: int | None | None = None) arkouda.numpy.pdarrayclass.pdarray[source]

Return the cumulative product over the array.

The product is inclusive, such that the i th element of the result is the product of elements up to and including i.

Parameters:
  • pda (pdarray)

  • axis (int, optional) – the axis along which to compute the product

Returns:

A pdarray containing cumulative products for each element of the original pdarray

Return type:

pdarray

Raises:
  • TypeError – Raised if the parameter is not a pdarray

  • ValueError – Raised if an invalid axis is given

Examples

>>> import arkouda as ak
>>> ak.cumprod(ak.arange(1,5))
array([1 2 6 24])
>>> ak.cumprod(ak.uniform(5,1.0,5.0, seed=1))
array([4.14859379... 5.54704379... 22.20109135... 79.7021268... 298.2655159...])
>>> ak.cumprod(ak.randint(0, 2, 5, dtype=ak.bool_, seed=1))
array([1 0 0 0 0])
arkouda.numpy.cumsum(pda: arkouda.numpy.pdarrayclass.pdarray, axis: int | None | None = None) arkouda.numpy.pdarrayclass.pdarray[source]

Return the cumulative sum over the array.

The sum is inclusive, such that the i th element of the result is the sum of elements up to and including i.

Parameters:
  • pda (pdarray)

  • axis (int, optional) – the axis along which to compute the sum

Returns:

A pdarray containing cumulative sums for each element of the original pdarray

Return type:

pdarray

Raises:
  • TypeError – Raised if the parameter is not a pdarray

  • ValueError – Raised if an invalid axis is given

Examples

>>> import arkouda as ak
>>> ak.cumsum(ak.arange(1,5))
array([1 3 6 10])
>>> ak.cumsum(ak.uniform(5,1.0,5.0, seed=1))
array([4.14859379... 5.48568392... 9.48801240... 13.0780218... 16.8202747...])
>>> ak.cumsum(ak.randint(0, 2, 5, dtype=ak.bool_, seed=1))
array([1 1 2 3 4])
arkouda.numpy.date_range(start=None, end=None, periods=None, freq=None, tz=None, normalize=False, name=None, inclusive='both', **kwargs)[source]

Create a fixed frequency Datetime range. Alias for ak.Datetime(pd.date_range(args)). Subject to size limit imposed by client.maxTransferBytes.

Parameters:
  • start (str or datetime-like, optional) – Left bound for generating dates.

  • end (str or datetime-like, optional) – Right bound for generating dates.

  • periods (int, optional) – Number of periods to generate.

  • freq (str or DateOffset, default 'D') – Frequency strings can have multiples, e.g. ‘5H’. See timeseries.offset_aliases for a list of frequency aliases.

  • tz (str or tzinfo, optional) – Time zone name for returning localized DatetimeIndex, for example ‘Asia/Hong_Kong’. By default, the resulting DatetimeIndex is timezone-naive.

  • normalize (bool, default False) – Normalize start/end dates to midnight before generating date range.

  • name (str, default None) – Name of the resulting DatetimeIndex.

  • inclusive ({"both", "neither", "left", "right"}, default "both") – Include boundaries. Whether to set each bound as closed or open.

  • **kwargs – For compatibility. Has no effect on the result.

Returns:

rng

Return type:

DatetimeIndex

Notes

Of the four parameters start, end, periods, and freq, exactly three must be specified. If freq is omitted, the resulting DatetimeIndex will have periods linearly spaced elements between start and end (closed on both sides).

To learn more about the frequency strings, please see this link.

class arkouda.numpy.datetime64

Bases: numpy.generic

If created from a 64-bit integer, it represents an offset from

1970-01-01T00:00:00. If created from string, the string can be in ISO 8601 date or datetime format.

When parsing a string to create a datetime object, if the string contains a trailing timezone (A ‘Z’ or a timezone offset), the timezone will be dropped and a User Warning is given.

Datetime64 objects should be considered to be UTC and therefore have an offset of +0000.

>>> np.datetime64(10, 'Y')
np.datetime64('1980')
>>> np.datetime64('1980', 'Y')
np.datetime64('1980')
>>> np.datetime64(10, 'D')
np.datetime64('1970-01-11')

See arrays.datetime for more information.

Character code:

'M'

arkouda.numpy.deg2rad(pda: arkouda.numpy.pdarrayclass.pdarray, where: bool | arkouda.numpy.pdarrayclass.pdarray = True) arkouda.numpy.pdarrayclass.pdarray[source]

Converts angles element-wise from degrees to radians.

Parameters:
  • pda (pdarray)

  • where (bool or pdarray, default=True) – This condition is broadcast over the input. At locations where the condition is True, the corresponding value will be converted from degrees to radians. Elsewhere, it will retain its original value. Default set to True.

Returns:

A pdarray containing an angle converted to radians, from degrees, for each element of the original pdarray

Return type:

pdarray

Raises:

TypeError – Raised if the parameter is not a pdarray

Examples

>>> import arkouda as ak
>>> a = ak.linspace(0,359,4)
>>> ak.deg2rad(a)
array([0.00000000... 2.08857733... 4.17715467... 6.26573201...])
arkouda.numpy.delete(arr: arkouda.numpy.pdarrayclass.pdarray, obj: slice | int | Sequence[int] | Sequence[bool] | arkouda.numpy.pdarrayclass.pdarray, axis: int | None = None) arkouda.numpy.pdarrayclass.pdarray[source]

Return a copy of ‘arr’ with elements along the specified axis removed.

Parameters:
  • arr (pdarray) – The array to remove elements from

  • obj (slice, int, Sequence of int, Sequence of bool, or pdarray) – The indices to remove from ‘arr’. If obj is a pdarray, it must have an integer or bool dtype.

  • axis (Optional[int], optional) – The axis along which to remove elements. If None, the array will be flattened before removing elements. Defaults to None.

Returns:

A copy of ‘arr’ with elements removed

Return type:

pdarray

Examples

>>> import arkouda as ak
>>> arr = ak.array([[1,2,3,4], [5,6,7,8], [9,10,11,12]])
>>> arr
array([array([1 2 3 4]) array([5 6 7 8]) array([9 10 11 12])])
>>> ak.delete(arr, 1, 0)
array([array([1 2 3 4]) array([9 10 11 12])])
>>> ak.delete(arr, slice(0, 4, 2), 1)
array([array([2 4]) array([6 8]) array([10 12])])
>>> ak.delete(arr, [1, 3, 5], None)
array([1 3 5 7 8 9 10 11 12])
arkouda.numpy.diff(a: pdarray, n: int = 1, axis: int = -1, prepend=None, append=None) pdarray[source]

Calculate the n-th discrete difference along the given axis.

The first difference is given by out[i] = a[i+1] - a[i] along the given axis, higher differences are calculated by using diff iteratively.

Parameters:
  • a (pdarray) – The array to calculate the difference

  • n (int, optional) – The order of the finite difference. Default is 1.

  • axis (int, optional) – The axis along which to calculate the difference. Default is the last axis.

  • prepend (pdarray, optional) – The pdarray to prepend to a along axis before calculating the difference.

  • append (pdarray, optional) – The pdarray to append to a along axis before calculating the difference.

Returns:

The n-th differences. The shape of the output is the same as a except along axis where the dimension is smaller by n. The type of the output is the same as the type of the difference between any two elements of a. This is the same as the type of a in most cases. A notable exception is datetime64, which results in a timedelta64 output array.

Return type:

pdarray

Notes

Type is preserved for boolean arrays, so the result will contain False when consecutive elements are the same and True when they differ.

For unsigned integer arrays, the results will also be unsigned. This should not be surprising, as the result is consistent with calculating the difference directly.

If this is not desirable, then the array should be cast to a larger integer type first:

Examples

>>> import arkouda as ak
>>> a = ak.array([1, 2, 4, 7, 0])
>>> ak.diff(a)
array([1 2 3 -7])
>>> ak.diff(a, n=2)
array([1 1 -10])
>>> a = ak.array([[1, 3, 6, 10], [0, 5, 6, 8]])
>>> ak.diff(a)
array([array([2 3 4]) array([5 1 2])])
>>> ak.diff(a, axis=0)
array([array([-1 2 0 -2])])
arkouda.numpy.divmod(x: arkouda.numpy.dtypes.numeric_scalars | pdarray, y: arkouda.numpy.dtypes.numeric_scalars | pdarray, where: arkouda.numpy.dtypes.bool_scalars | pdarray = True) Tuple[pdarray, pdarray][source]
Parameters:
  • x (numeric_scalars(float_scalars, int_scalars) or pdarray) – The dividend array, the values that will be the numerator of the floordivision and will be acted on by the bases for modular division.

  • y (numeric_scalars(float_scalars, int_scalars) or pdarray) – The divisor array, the values that will be the denominator of the division and will be the bases for the modular division.

  • where (Boolean or pdarray) – This condition is broadcast over the input. At locations where the condition is True, the corresponding value will be divided using floor and modular division. Elsewhere, it will retain its original value. Default set to True.

Returns:

Returns a tuple that contains quotient and remainder of the division

Return type:

(pdarray, pdarray)

Raises:
  • TypeError – At least one entry must be a pdarray

  • ValueError – If both inputs are both pdarrays, their size must match

  • ZeroDivisionError – No entry in y is allowed to be 0, to prevent division by zero

Notes

The div is calculated by x // y The mod is calculated by x % y

Examples

>>> import arkouda as ak
>>> x = ak.arange(5, 10)
>>> y = ak.array([2, 1, 4, 5, 8])
>>> ak.divmod(x,y)
(array([2 6 1 1 1]), array([1 0 3 3 1]))
>>> ak.divmod(x,y, x % 2 == 0)
(array([5 6 7 1 9]), array([5 0 7 3 9]))
arkouda.numpy.dot(pda1: int | numpy.int64 | numpy.float64 | numpy.uint64 | pdarray, pda2: int | numpy.int64 | numpy.float64 | numpy.uint64 | pdarray) arkouda.numpy.dtypes.numeric_scalars | numpy.bool | pdarray[source]

Computes dot product of two arrays.

If pda1 and pda2 are 1-D vectors of identical length, returns the conventional dot product.

If both pda1 and pda2 are scalars, returns their product.

If one of pda1, pda2 is a scalar, and the other a pdarray, returns the pdarray multiplied by the scalar.

If both pda1 and pda2 are 2-D arrays, returns the matrix multiplication.

If pda1 is M-D and pda2 is 1-D, returns a sum product over the last axis of pda1 and pda2.

If pda1 is M-D and pda2 is N-D, returns a sum product over the last axis of pda1 and the next-to-last axis of pda2, e.g.:

For example, If pda1 has rank (3,3,4) and pda2 has rank (4,2), then the result of ak.dot(pda1,pda2) has rank (3,3,2), and

result[i,j,k] = sum( pda1[i, j, :] * pda2[:, k] )

Parameters:
Returns:

as described above

Return type:

Union[numeric_scalars, pdarray]

Examples

>>> import arkouda as ak
>>> ak.dot(ak.array([1, 2, 3]),ak.array([4,5,6]))
np.int64(32)
>>> ak.dot(ak.array([1, 2, 3]),5)
array([5 10 15])
>>> ak.dot(5,ak.array([2, 3, 4]))
array([10 15 20])
>>> ak.dot(ak.arange(9).reshape(3,3),ak.arange(6).reshape(3,2))
array([array([10 13]) array([28 40]) array([46 67])])
>>> ak.dot(ak.arange(27).reshape(3,3,3),ak.array([2,3,4]))
array([array([11 38 65]) array([92 119 146]) array([173 200 227])])
>>> ak.dot(ak.arange(36).reshape(3,3,4),ak.arange(8).reshape(4,2))
array([array([array([28 34]) array([76 98]) array([124 162])]) array([array([172 226])
    array([220 290]) array([268 354])]) array([array([316 418]) array([364 482]) array([412 546])])])
Raises:

ValueError – Raised if either pdda1 or pda2 is not an allowed type, or if shapes are incompatible.

class arkouda.numpy.double

Bases: numpy.floating

Double-precision floating-point number type, compatible with Python

float and C double.

Character code:

'd'

Canonical name:

numpy.double

Alias on this platform (Linux x86_64):

numpy.float64: 64-bit precision floating-point number type: sign bit, 11 bits exponent, 52 bits mantissa.

as_integer_ratio(/)

double.as_integer_ratio() -> (int, int)

Return a pair of integers, whose ratio is exactly equal to the original floating point number, and with a positive denominator. Raise OverflowError on infinities and a ValueError on NaNs.

>>> np.double(10.0).as_integer_ratio()
(10, 1)
>>> np.double(0.0).as_integer_ratio()
(0, 1)
>>> np.double(-.25).as_integer_ratio()
(-1, 4)
fromhex(string, /)

Create a floating-point number from a hexadecimal string.

>>> float.fromhex('0x1.ffffp10')
2047.984375
>>> float.fromhex('-0x1p-1074')
-5e-324
hex(/)

Return a hexadecimal representation of a floating-point number.

>>> (-0.1).hex()
'-0x1.999999999999ap-4'
>>> 3.14159.hex()
'0x1.921f9f01b866ep+1'
is_integer(/)

double.is_integer() -> bool

Return True if the floating point number is finite with integral value, and False otherwise.

Added in version 1.22.

>>> np.double(-2.0).is_integer()
True
>>> np.double(3.2).is_integer()
False
arkouda.numpy.dtype(x)[source]

Normalize a dtype-like input into an Arkouda dtype sentinel or a NumPy dtype.

This function accepts many dtype-like forms—including Python scalars, NumPy scalar types, Arkouda bigint sentinels, and strings—and resolves them to the canonical Arkouda/NumPy dtype object. The resolution rules include special handling of the bigint family and magnitude-aware routing for Python integers.

Parameters:

x (Any) – The dtype-like object to normalize. May be a Python scalar, a NumPy dtype or scalar, the bigint sentinel or scalar, a dtype-specifying string, or any object accepted by numpy.dtype.

Raises:

TypeError – If x cannot be interpreted as either an Arkouda dtype or a NumPy dtype. This includes cases where numpy.dtype(x) itself fails.

Examples

>>> import arkouda as ak
>>> from arkouda.numpy import dtype

# bigint family >>> dtype(“bigint”) dtype(bigint) >>> dtype(ak.bigint(10_000_000_000_000_000_000)) dtype(bigint)

# magnitude-based routing for Python ints >>> dtype(10) dtype(‘int64’) >>> dtype(2**63 - 1) dtype(‘int64’) >>> dtype(2**63) dtype(‘uint64’) >>> dtype(2**100) dtype(bigint)

# floats and bools >>> dtype(1.0) dtype(‘float64’) >>> dtype(True) dtype(‘bool’)

# string dtypes >>> dtype(“str”) dtype(‘<U’)

# fallback to numpy.dtype >>> dtype(“int32”) dtype(‘int32’)

arkouda.numpy.e: float
arkouda.numpy.errstate(*, divide: _ErrorMode | None = None, over: _ErrorMode | None = None, under: _ErrorMode | None = None, invalid: _ErrorMode | None = None, call: Callable[[str, str], None] | None = None) Iterator[None][source]

Context manager to temporarily set floating-point error handling.

Parameters:
  • divide ({'ignore', 'warn', 'raise', 'call', 'print', 'log'}, optional) – Temporary behavior within the context.

  • over ({'ignore', 'warn', 'raise', 'call', 'print', 'log'}, optional) – Temporary behavior within the context.

  • under ({'ignore', 'warn', 'raise', 'call', 'print', 'log'}, optional) – Temporary behavior within the context.

  • invalid ({'ignore', 'warn', 'raise', 'call', 'print', 'log'}, optional) – Temporary behavior within the context.

  • call (callable or None, optional) – Temporary callable used if any category is set to ‘call’. Signature: (errtype: str, message: str) -> None.

Yields:

None – This context manager does not return a value. Code inside the with block will be executed with the temporary error handling settings.

Examples

>>> import arkouda as ak
>>> ak.geterr()
{'divide': 'call', 'over': 'ignore', 'under': 'ignore', 'invalid': 'ignore'}
>>> with ak.errstate(divide='warn'):
...     _ = ak.array([1.0]) / 0  # gives a warning
>>> ak.geterr()['divide']
'ignore'

Notes

This affects only stored policy; it does not add runtime checks by itself.

arkouda.numpy.euler_gamma: float
arkouda.numpy.exp(pda: arkouda.numpy.pdarrayclass.pdarray) arkouda.numpy.pdarrayclass.pdarray[source]

Return the element-wise exponential of the array.

Parameters:

pda (pdarray)

Returns:

A pdarray containing exponential values of the input array elements

Return type:

pdarray

Raises:

TypeError – Raised if the parameter is not a pdarray

Examples

>>> import arkouda as ak
>>> ak.exp(ak.arange(1,5))
array([2.71828182... 7.38905609... 20.0855369... 54.5981500...])
>>> ak.exp(ak.uniform(4, 1.0, 5.0, seed=1))
array([63.3448620... 3.80794671... 54.7254287... 36.2344168...])
arkouda.numpy.expm1(pda: arkouda.numpy.pdarrayclass.pdarray) arkouda.numpy.pdarrayclass.pdarray[source]

Return the element-wise exponential of the array minus one.

Parameters:

pda (pdarray)

Returns:

A pdarray containing e raised to each of the inputs, then subtracting one.

Return type:

pdarray

Raises:

TypeError – Raised if the parameter is not a pdarray

Examples

>>> import arkouda as ak
>>> ak.expm1(ak.arange(1,5))
array([1.71828182... 6.38905609... 19.0855369... 53.5981500...])
>>> ak.expm1(ak.uniform(5,1.0,5.0, seed=1))
array([62.3448620... 2.80794671... 53.7254287...
    35.2344168... 41.1929399...])
arkouda.numpy.eye(N: arkouda.numpy.dtypes.int_scalars, M: arkouda.numpy.dtypes.int_scalars, k: arkouda.numpy.dtypes.int_scalars = 0, dt: type = ak_float64) arkouda.numpy.pdarrayclass.pdarray[source]

Return a pdarray with zeros everywhere except along a diagonal, which is all ones. The matrix need not be square.

Parameters:
  • N (int_scalars)

  • M (int_scalars)

  • k (int_scalars, default=0) –

    if k = 0, zeros start at element [0,0] and proceed along diagonal
    if k > 0, zeros start at element [0,k] and proceed along diagonal
    if k < 0, zeros start at element [k,0] and proceed along diagonal

  • dt (type, default=ak_float64) – The data type of the elements in the matrix being returned. Default set to ak_float64

Returns:

an array of zeros with ones along the specified diagonal

Return type:

pdarray

Examples

>>> import arkouda as ak
>>> ak.eye(N=4,M=4,k=0,dt=ak.int64)
array([array([1 0 0 0]) array([0 1 0 0]) array([0 0 1 0]) array([0 0 0 1])])
>>> ak.eye(N=3,M=3,k=1,dt=ak.float64)
array([array([0.00000000... 1.00000000... 0.00000000...])
array([0.00000000... 0.00000000... 1.00000000...])
array([0.00000000... 0.00000000... 0.00000000...])])
>>> ak.eye(N=4,M=4,k=-1,dt=ak.bool_)
array([array([False False False False]) array([True False False False])
array([False True False False]) array([False False True False])])

Notes

if N = M and k = 0, the result is an identity matrix Server returns an error if rank of pda < 2

arkouda.numpy.fabs(pda: arkouda.numpy.pdarrayclass.pdarray) arkouda.numpy.pdarrayclass.pdarray[source]

Compute the absolute values element-wise, casting to a float beforehand.

Parameters:

pda (pdarray)

Returns:

A pdarray containing absolute values of the input array elements, casted to float type

Return type:

pdarray

Raises:

TypeError – Raised if the parameter is not a pdarray

Examples

>>> import arkouda as ak
>>> ak.fabs(ak.arange(-5,-1))
array([5.00000000000000000 4.00000000000000000 3.00000000000000000 2.00000000000000000])
>>> ak.fabs(ak.linspace(-5,-1,5))
array([5.00000000... 4.00000000... 3.00000000...
2.00000000... 1.00000000...])
arkouda.numpy.find(query, space, all_occurrences=False, remove_missing=False)[source]

Return indices of query items in a search list of items.

Parameters:
  • query ((sequence of) array-like) – The items to search for. If multiple arrays, each “row” is an item.

  • space ((sequence of) array-like) – The set of items in which to search. Must have same shape/dtype as query.

  • all_occurrences (bool) – When duplicate terms are present in search space, if all_occurrences is True, return all occurrences found as a SegArray, otherwise return only the first occurrences as a pdarray. Defaults to only finding the first occurrence. Finding all occurrences is not yet supported on sequences of arrays

  • remove_missing (bool) – If all_occurrences is True, remove_missing is automatically enabled. If False, return -1 for any items in query not found in space. If True, remove these and only return indices of items that are found.

Returns:

indices – For each item in query, its index in space. If all_occurrences is False, the return will be a pdarray of the first index where each value in the query appears in the space. If all_occurrences is True, the return will be a SegArray containing every index where each value in the query appears in the space. If all_occurrences is True, remove_missing is automatically enabled. If remove_missing is True, exclude missing values, otherwise return -1.

Return type:

pdarray or SegArray

Examples

>>> import arkouda as ak
>>> select_from = ak.arange(10)
>>> arr1 = select_from[ak.randint(0, select_from.size, 20, seed=10)]
>>> arr2 = select_from[ak.randint(0, select_from.size, 20, seed=11)]

Remove some values to ensure we have some values which don’t appear in the search space

>>> arr2 = arr2[arr2 != 9]
>>> arr2 = arr2[arr2 != 3]

Find with defaults (all_occurrences and remove_missing both False)

>>> ak.numpy.alignment.find(arr1, arr2)
array([-1 -1 -1 0 1 -1 -1 -1 2 -1 5 -1 8 -1 5 -1 -1 11 5 0])

Set remove_missing to True, only difference from default is missing values are excluded

>>> ak.numpy.alignment.find(arr1, arr2, remove_missing=True)
array([0 1 2 5 8 5 11 5 0])

Set both remove_missing and all_occurrences to True, missing values will be empty segments

>>> ak.numpy.alignment.find(arr1, arr2, remove_missing=True, all_occurrences=True).tolist()
[[],
 [],
 [],
 [0, 4],
 [1, 3, 10],
 [],
 [],
 [],
 [2, 6, 12, 13],
 [],
 [5, 7],
 [],
 [8, 9, 14],
 [],
 [5, 7],
 [],
 [],
 [11, 15],
 [5, 7],
 [0, 4]]
class arkouda.numpy.finfo

finfo(dtype)

Machine limits for floating point types.

bits

The number of bits occupied by the type.

Type:

int

dtype

Returns the dtype for which finfo returns information. For complex input, the returned dtype is the associated float* dtype for its real and complex components.

Type:

dtype

eps

The difference between 1.0 and the next smallest representable float larger than 1.0. For example, for 64-bit binary floats in the IEEE-754 standard, eps = 2**-52, approximately 2.22e-16.

Type:

float

epsneg

The difference between 1.0 and the next smallest representable float less than 1.0. For example, for 64-bit binary floats in the IEEE-754 standard, epsneg = 2**-53, approximately 1.11e-16.

Type:

float

iexp

The number of bits in the exponent portion of the floating point representation.

Type:

int

machep

The exponent that yields eps.

Type:

int

max

The largest representable number.

Type:

floating point number of the appropriate type

maxexp

The smallest positive power of the base (2) that causes overflow.

Type:

int

min

The smallest representable number, typically -max.

Type:

floating point number of the appropriate type

minexp

The most negative power of the base (2) consistent with there being no leading 0’s in the mantissa.

Type:

int

negep

The exponent that yields epsneg.

Type:

int

nexp

The number of bits in the exponent including its sign and bias.

Type:

int

nmant

The number of bits in the mantissa.

Type:

int

precision

The approximate number of decimal digits to which this kind of float is precise.

Type:

int

resolution

The approximate decimal resolution of this type, i.e., 10**-precision.

Type:

floating point number of the appropriate type

tiny

An alias for smallest_normal, kept for backwards compatibility.

Type:

float

smallest_normal

The smallest positive floating point number with 1 as leading bit in the mantissa following IEEE-754 (see Notes).

Type:

float

smallest_subnormal

The smallest positive floating point number with 0 as leading bit in the mantissa following IEEE-754.

Type:

float

Parameters:

dtype (float, dtype, or instance) – Kind of floating point or complex floating point data-type about which to get information.

See also

iinfo

The equivalent for integer data types.

spacing

The distance between a value and the nearest adjacent number

nextafter

The next floating point value after x1 towards x2

Notes

For developers of NumPy: do not instantiate this at the module level. The initial calculation of these parameters is expensive and negatively impacts import times. These objects are cached, so calling finfo() repeatedly inside your functions is not a problem.

Note that smallest_normal is not actually the smallest positive representable value in a NumPy floating point type. As in the IEEE-754 standard [1]_, NumPy floating point types make use of subnormal numbers to fill the gap between 0 and smallest_normal. However, subnormal numbers may have significantly reduced precision [2].

This function can also be used for complex data types as well. If used, the output will be the same as the corresponding real float type (e.g. numpy.finfo(numpy.csingle) is the same as numpy.finfo(numpy.single)). However, the output is true for the real and imaginary components.

References

Examples

>>> import numpy as np
>>> np.finfo(np.float64).dtype
dtype('float64')
>>> np.finfo(np.complex64).dtype
dtype('float32')
property smallest_normal

Return the value for the smallest normal.

Returns:

smallest_normal – Value for the smallest normal.

Return type:

float

Warns:

UserWarning – If the calculated value for the smallest normal is requested for double-double.

property tiny

Return the value for tiny, alias of smallest_normal.

Returns:

tiny – Value for the smallest normal, alias of smallest_normal.

Return type:

float

Warns:

UserWarning – If the calculated value for the smallest normal is requested for double-double.

class arkouda.numpy.flexible

Bases: numpy.generic

Abstract base class of all scalar types without predefined length.

The actual size of these types depends on the specific numpy.dtype instantiation.

arkouda.numpy.flip(x: arkouda.numpy.pdarrayclass.pdarray, /, *, axis: arkouda.numpy.dtypes.int_scalars | Tuple[arkouda.numpy.dtypes.int_scalars, Ellipsis] | None = None) arkouda.numpy.pdarrayclass.pdarray[source]
arkouda.numpy.flip(x: arkouda.numpy.strings.Strings, /, *, axis: arkouda.numpy.dtypes.int_scalars | Tuple[arkouda.numpy.dtypes.int_scalars, Ellipsis] | None = None) arkouda.numpy.strings.Strings
arkouda.numpy.flip(x: arkouda.pandas.categorical.Categorical, /, *, axis: arkouda.numpy.dtypes.int_scalars | Tuple[arkouda.numpy.dtypes.int_scalars, Ellipsis] | None = None) arkouda.pandas.categorical.Categorical

Reverse an array’s values along a particular axis or axes.

Parameters:
  • x (pdarray, Strings, or Categorical) –

    Reverse the order of elements in an array along the given axis.

    The shape of the array is preserved, but the elements are reordered.

  • axis (int or Tuple[int, ...], optional) – The axis or axes along which to flip the array. If None, flip the array along all axes.

Returns:

An array with the entries of axis reversed.

Return type:

pdarray, Strings, or Categorical

Raises:

IndexError – Raised if operation fails server-side.

Examples

>>> import arkouda as ak
>>> a = ak.arange(12)
>>> ak.flip(a)
array([11 10 9 8 7 6 5 4 3 2 1 0])

Note

This differs from numpy as it actually reverses the data, rather than presenting a view.

class arkouda.numpy.float16

Bases: numpy.floating

Half-precision floating-point number type.

Character code:

'e'

Canonical name:

numpy.half

Alias on this platform (Linux x86_64):

numpy.float16: 16-bit-precision floating-point number type: sign bit, 5 bits exponent, 10 bits mantissa.

as_integer_ratio(/)

half.as_integer_ratio() -> (int, int)

Return a pair of integers, whose ratio is exactly equal to the original floating point number, and with a positive denominator. Raise OverflowError on infinities and a ValueError on NaNs.

>>> np.half(10.0).as_integer_ratio()
(10, 1)
>>> np.half(0.0).as_integer_ratio()
(0, 1)
>>> np.half(-.25).as_integer_ratio()
(-1, 4)
is_integer(/)

half.is_integer() -> bool

Return True if the floating point number is finite with integral value, and False otherwise.

Added in version 1.22.

>>> np.half(-2.0).is_integer()
True
>>> np.half(3.2).is_integer()
False
class arkouda.numpy.float32

Bases: numpy.floating

Single-precision floating-point number type, compatible with C float.

Character code:

'f'

Canonical name:

numpy.single

Alias on this platform (Linux x86_64):

numpy.float32: 32-bit-precision floating-point number type: sign bit, 8 bits exponent, 23 bits mantissa.

as_integer_ratio(/)

single.as_integer_ratio() -> (int, int)

Return a pair of integers, whose ratio is exactly equal to the original floating point number, and with a positive denominator. Raise OverflowError on infinities and a ValueError on NaNs.

>>> np.single(10.0).as_integer_ratio()
(10, 1)
>>> np.single(0.0).as_integer_ratio()
(0, 1)
>>> np.single(-.25).as_integer_ratio()
(-1, 4)
is_integer(/)

single.is_integer() -> bool

Return True if the floating point number is finite with integral value, and False otherwise.

Added in version 1.22.

>>> np.single(-2.0).is_integer()
True
>>> np.single(3.2).is_integer()
False
class arkouda.numpy.float64

Bases: numpy.floating

Double-precision floating-point number type, compatible with Python

float and C double.

Character code:

'd'

Canonical name:

numpy.double

Alias on this platform (Linux x86_64):

numpy.float64: 64-bit precision floating-point number type: sign bit, 11 bits exponent, 52 bits mantissa.

as_integer_ratio(/)

double.as_integer_ratio() -> (int, int)

Return a pair of integers, whose ratio is exactly equal to the original floating point number, and with a positive denominator. Raise OverflowError on infinities and a ValueError on NaNs.

>>> np.double(10.0).as_integer_ratio()
(10, 1)
>>> np.double(0.0).as_integer_ratio()
(0, 1)
>>> np.double(-.25).as_integer_ratio()
(-1, 4)
fromhex(string, /)

Create a floating-point number from a hexadecimal string.

>>> float.fromhex('0x1.ffffp10')
2047.984375
>>> float.fromhex('-0x1p-1074')
-5e-324
hex(/)

Return a hexadecimal representation of a floating-point number.

>>> (-0.1).hex()
'-0x1.999999999999ap-4'
>>> 3.14159.hex()
'0x1.921f9f01b866ep+1'
is_integer(/)

double.is_integer() -> bool

Return True if the floating point number is finite with integral value, and False otherwise.

Added in version 1.22.

>>> np.double(-2.0).is_integer()
True
>>> np.double(3.2).is_integer()
False
class arkouda.numpy.float_scalars

Bases: _NotIterable

Mixin to prevent iteration, without being compatible with Iterable.

That is, we could do:

def __iter__(self): raise TypeError()

But this would make users of this mixin duck type-compatible with collections.abc.Iterable - isinstance(foo, Iterable) would be True.

Luckily, we can instead prevent iteration by setting __iter__ to None, which is treated specially.

copy_with(params)
class arkouda.numpy.floating

Bases: numpy.inexact

Abstract base class of all floating-point scalar types.

arkouda.numpy.floor(pda: arkouda.numpy.pdarrayclass.pdarray, where: bool | arkouda.numpy.pdarrayclass.pdarray = True) arkouda.numpy.pdarrayclass.pdarray[source]

Return the element-wise floor of the array.

Parameters:
  • pda (pdarray)

  • where (bool or pdarray, default=True) – This condition is applied over the input. At locations where the condition is True, the corresponding value will be acted on by the function. Elsewhere, it will retain its original value. Default set to True.

Returns:

A pdarray containing floor values of the input array elements

Return type:

pdarray

Raises:

TypeError – Raised if the parameter is not a pdarray

Examples

>>> import arkouda as ak
>>> ak.floor(ak.linspace(1.1,5.5,5))
array([1.00000000... 2.00000000... 3.00000000...
4.00000000... 5.00000000...])
arkouda.numpy.fmod(dividend: pdarray | arkouda.numpy.dtypes.numeric_scalars, divisor: pdarray | arkouda.numpy.dtypes.numeric_scalars) pdarray[source]

Returns the element-wise remainder of division.

It is equivalent to np.fmod, the remainder has the same sign as the dividend.

Parameters:
  • dividend (numeric scalars or pdarray) – The array being acted on by the bases for the modular division.

  • divisor (numeric scalars or pdarray) – The array that will be the bases for the modular division.

Returns:

an array that contains the element-wise remainder of division.

Return type:

pdarray

Raises:

TypeError – Raised if neither dividend nor divisor is a pdarray (at least one must be) or if any scalar or pdarray element is not one of int, uint, float, bigint

arkouda.numpy.format_float_positional(x, precision=None, unique=True, fractional=True, trim='k', sign=False, pad_left=None, pad_right=None, min_digits=None)

Format a floating-point scalar as a decimal string in positional notation.

Provides control over rounding, trimming and padding. Uses and assumes IEEE unbiased rounding. Uses the “Dragon4” algorithm.

Parameters:
  • x (python float or numpy floating scalar) – Value to format.

  • precision (non-negative integer or None, optional) – Maximum number of digits to print. May be None if unique is True, but must be an integer if unique is False.

  • unique (boolean, optional) – If True, use a digit-generation strategy which gives the shortest representation which uniquely identifies the floating-point number from other values of the same type, by judicious rounding. If precision is given fewer digits than necessary can be printed, or if min_digits is given more can be printed, in which cases the last digit is rounded with unbiased rounding. If False, digits are generated as if printing an infinite-precision value and stopping after precision digits, rounding the remaining value with unbiased rounding

  • fractional (boolean, optional) – If True, the cutoffs of precision and min_digits refer to the total number of digits after the decimal point, including leading zeros. If False, precision and min_digits refer to the total number of significant digits, before or after the decimal point, ignoring leading zeros.

  • trim (one of 'k', '.', '0', '-', optional) –

    Controls post-processing trimming of trailing digits, as follows:

    • ’k’ : keep trailing zeros, keep decimal point (no trimming)

    • ’.’ : trim all trailing zeros, leave decimal point

    • ’0’ : trim all but the zero before the decimal point. Insert the zero if it is missing.

    • ’-’ : trim trailing zeros and any trailing decimal point

  • sign (boolean, optional) – Whether to show the sign for positive values.

  • pad_left (non-negative integer, optional) – Pad the left side of the string with whitespace until at least that many characters are to the left of the decimal point.

  • pad_right (non-negative integer, optional) – Pad the right side of the string with whitespace until at least that many characters are to the right of the decimal point.

  • min_digits (non-negative integer or None, optional) –

    Minimum number of digits to print. Only has an effect if unique=True in which case additional digits past those necessary to uniquely identify the value may be printed, rounding the last additional digit.

    Added in version 1.21.0.

Returns:

rep – The string representation of the floating point value

Return type:

string

Examples

>>> import numpy as np
>>> np.format_float_positional(np.float32(np.pi))
'3.1415927'
>>> np.format_float_positional(np.float16(np.pi))
'3.14'
>>> np.format_float_positional(np.float16(0.3))
'0.3'
>>> np.format_float_positional(np.float16(0.3), unique=False, precision=10)
'0.3000488281'
arkouda.numpy.format_float_scientific(x, precision=None, unique=True, trim='k', sign=False, pad_left=None, exp_digits=None, min_digits=None)

Format a floating-point scalar as a decimal string in scientific notation.

Provides control over rounding, trimming and padding. Uses and assumes IEEE unbiased rounding. Uses the “Dragon4” algorithm.

Parameters:
  • x (python float or numpy floating scalar) – Value to format.

  • precision (non-negative integer or None, optional) – Maximum number of digits to print. May be None if unique is True, but must be an integer if unique is False.

  • unique (boolean, optional) – If True, use a digit-generation strategy which gives the shortest representation which uniquely identifies the floating-point number from other values of the same type, by judicious rounding. If precision is given fewer digits than necessary can be printed. If min_digits is given more can be printed, in which cases the last digit is rounded with unbiased rounding. If False, digits are generated as if printing an infinite-precision value and stopping after precision digits, rounding the remaining value with unbiased rounding

  • trim (one of 'k', '.', '0', '-', optional) –

    Controls post-processing trimming of trailing digits, as follows:

    • ’k’ : keep trailing zeros, keep decimal point (no trimming)

    • ’.’ : trim all trailing zeros, leave decimal point

    • ’0’ : trim all but the zero before the decimal point. Insert the zero if it is missing.

    • ’-’ : trim trailing zeros and any trailing decimal point

  • sign (boolean, optional) – Whether to show the sign for positive values.

  • pad_left (non-negative integer, optional) – Pad the left side of the string with whitespace until at least that many characters are to the left of the decimal point.

  • exp_digits (non-negative integer, optional) – Pad the exponent with zeros until it contains at least this many digits. If omitted, the exponent will be at least 2 digits.

  • min_digits (non-negative integer or None, optional) –

    Minimum number of digits to print. This only has an effect for unique=True. In that case more digits than necessary to uniquely identify the value may be printed and rounded unbiased.

    Added in version 1.21.0.

Returns:

rep – The string representation of the floating point value

Return type:

string

Examples

>>> import numpy as np
>>> np.format_float_scientific(np.float32(np.pi))
'3.1415927e+00'
>>> s = np.float32(1.23e24)
>>> np.format_float_scientific(s, unique=False, precision=15)
'1.230000071797338e+24'
>>> np.format_float_scientific(s, exp_digits=4)
'1.23e+0024'
arkouda.numpy.full(size: arkouda.numpy.dtypes.int_scalars | Tuple[arkouda.numpy.dtypes.int_scalars, Ellipsis] | str, fill_value: arkouda.numpy.dtypes.numeric_scalars | numpy.bool | str, dtype: numpy.dtype | type | str | arkouda.numpy.dtypes.bigint = float64, max_bits: int | None = None) arkouda.numpy.pdarrayclass.pdarray | arkouda.numpy.strings.Strings[source]

Create a pdarray filled with fill_value.

Parameters:
  • size (int_scalars or tuple of int_scalars) – Size or shape of the array

  • fill_value (int_scalars or str) – Value with which the array will be filled

  • dtype (all_scalars) – Resulting array type, default float64

  • max_bits (int) – Specifies the maximum number of bits; only used for bigint pdarrays

Returns:

array of the requested size and dtype filled with fill_value

Return type:

pdarray or Strings

Raises:
  • TypeError – Raised if the supplied dtype is not supported

  • RuntimeError – Raised if the size parameter is neither an int nor a str that is parseable to an int.

  • ValueError – Raised if the rank of the given shape is not in get_array_ranks() or is empty Raised if max_bits is not NONE and ndim does not equal 1

See also

zeros, ones

Examples

>>> import arkouda as ak
>>> ak.full(5, 7, dtype=ak.int64)
array([7 7 7 7 7])
>>> ak.full(5, 9, dtype=ak.float64)
array([9.00000000000000000 9.00000000000000000 9.00000000000000000
       9.00000000000000000 9.00000000000000000])
>>> ak.full(5, 5, dtype=ak.bool_)
array([True True True True True])
arkouda.numpy.full_like(pda: arkouda.numpy.pdarrayclass.pdarray, fill_value: arkouda.numpy.dtypes.numeric_scalars) arkouda.numpy.pdarrayclass.pdarray | arkouda.numpy.strings.Strings[source]

Create a pdarray filled with fill_value of the same size and dtype as an existing pdarray.

Parameters:
  • pda (pdarray) – Array to use for shape and dtype

  • fill_value (int_scalars) – Value with which the array will be filled

Returns:

Equivalent to ak.full(pda.shape, fill_value, pda.dtype)

Return type:

pdarray

Raises:

TypeError – Raised if the pda parameter is not a pdarray.

See also

ones_like, zeros_like

Notes

Logic for generating the pdarray is delegated to the ak.full method. Accordingly, the supported dtypes match are defined by the ak.full method.

Examples

>>> import arkouda as ak
>>> ak.full_like(ak.full(5,7,dtype=ak.int64),6)
array([6 6 6 6 6])
>>> ak.full_like(ak.full(7,9,dtype=ak.float64),10)
array([10.00000000000000000 10.00000000000000000 10.00000000000000000
       10.00000000000000000 10.00000000000000000 10.00000000000000000 10.00000000000000000])
>>> ak.full_like(ak.full(5,True,dtype=ak.bool_),False)
array([False False False False False])
arkouda.numpy.get_byteorder(dt: np.dtype) str[source]

Get a concrete byteorder (turns ‘=’ into ‘<’ or ‘>’) on the client.

Parameters:

dt (np.dtype) – The numpy dtype to determine the byteorder of.

Returns:

Returns “<” for little endian and “>” for big endian.

Return type:

str

Raises:

ValueError – Returned if sys.byteorder is not “little” or “big”

Examples

>>> import arkouda as ak
>>> ak.get_byteorder(ak.dtype(ak.int64))
'<'
arkouda.numpy.get_server_byteorder() str[source]

Get the server’s byteorder.

Returns:

Returns “little” for little endian and “big” for big endian.

Return type:

str

Raises:

ValueError – Raised if Server byteorder is not ‘little’ or ‘big’

Examples

>>> import arkouda as ak
>>> ak.get_server_byteorder()
'little'
arkouda.numpy.geterr() Dict[str, _ErrorMode][source]

Get the current Arkouda floating-point error handling settings.

Returns:

Mapping of {‘divide’, ‘over’, ‘under’, ‘invalid’} to one of {‘ignore’, ‘warn’, ‘raise’, ‘call’, ‘print’, ‘log’}.

Return type:

dict

arkouda.numpy.geterrcall() Callable[[str, str], None] | None[source]

Get the current callable used when error mode is ‘call’.

Returns:

A function of signature (errtype: str, message: str) -> None, or None.

Return type:

callable or None

class arkouda.numpy.half

Bases: numpy.floating

Half-precision floating-point number type.

Character code:

'e'

Canonical name:

numpy.half

Alias on this platform (Linux x86_64):

numpy.float16: 16-bit-precision floating-point number type: sign bit, 5 bits exponent, 10 bits mantissa.

as_integer_ratio(/)

half.as_integer_ratio() -> (int, int)

Return a pair of integers, whose ratio is exactly equal to the original floating point number, and with a positive denominator. Raise OverflowError on infinities and a ValueError on NaNs.

>>> np.half(10.0).as_integer_ratio()
(10, 1)
>>> np.half(0.0).as_integer_ratio()
(0, 1)
>>> np.half(-.25).as_integer_ratio()
(-1, 4)
is_integer(/)

half.is_integer() -> bool

Return True if the floating point number is finite with integral value, and False otherwise.

Added in version 1.22.

>>> np.half(-2.0).is_integer()
True
>>> np.half(3.2).is_integer()
False
arkouda.numpy.hash(pda: HashableItems, full: Literal[True] = True) Tuple[arkouda.numpy.pdarrayclass.pdarray, arkouda.numpy.pdarrayclass.pdarray][source]
arkouda.numpy.hash(pda: HashableItems, full: Literal[False]) arkouda.numpy.pdarrayclass.pdarray
arkouda.numpy.hash(pda: HashableList, full: Literal[True] = True) Tuple[arkouda.numpy.pdarrayclass.pdarray, arkouda.numpy.pdarrayclass.pdarray]
arkouda.numpy.hash(pda: HashableList, full: Literal[False]) arkouda.numpy.pdarrayclass.pdarray

Return an element-wise hash of the array or list of arrays.

Parameters:
  • pda (pdarray, Strings, SegArray, or Categorical or List of pdarray, Strings, SegArray, or Categorical)

  • full (bool, default=True) – This is only used when a single pdarray is passed into hash By default, a 128-bit hash is computed and returned as two int64 arrays. If full=False, then a 64-bit hash is computed and returned as a single int64 array.

Returns:

If full=True or a list of pdarrays is passed, a 2-tuple of pdarrays containing the high and low 64 bits of each hash, respectively. If full=False and a single pdarray is passed, a single pdarray containing a 64-bit hash

Return type:

hashes

Raises:

TypeError – Raised if the parameter is not a pdarray

Examples

>>> import arkouda as ak
>>> a = ak.randint(0,65536,3,seed=8675309)
>>> ak.hash(a,full=False)
array([6132219720275344925 189443193828113335 14797568559700425150])
>>> ak.hash(a)
(array([12228890592923494910 17773622519799422780 16661993598191972647]),
    array([2936052102410048944 15730675498625067356 4746877828134486787]))

Notes

In the case of a single pdarray being passed, this function uses the SIPhash algorithm, which can output either a 64-bit or 128-bit hash. However, the 64-bit hash runs a significant risk of collisions when applied to more than a few million unique values. Unless the number of unique values is known to be small, the 128-bit hash is strongly recommended.

Note that this hash should not be used for security, or for any cryptographic application. Not only is SIPhash not intended for such uses, but this implementation employs a fixed key for the hash, which makes it possible for an adversary with control over input to engineer collisions.

In the case of a list of pdrrays, Strings, Categoricals, or Segarrays being passed, a non-linear function must be applied to each array since hashes of subsequent arrays cannot be simply XORed because equivalent values will cancel each other out, hence we do a rotation by the ordinal of the array.

arkouda.numpy.histogram(pda: arkouda.numpy.pdarrayclass.pdarray, bins: arkouda.numpy.dtypes.int_scalars = 10, range: Tuple[arkouda.numpy.dtypes.numeric_scalars, arkouda.numpy.dtypes.numeric_scalars] | None = None) Tuple[arkouda.numpy.pdarrayclass.pdarray, arkouda.numpy.pdarrayclass.pdarray][source]

Compute a histogram of evenly spaced bins over the range of an array.

Parameters:
  • pda (pdarray) – The values to histogram

  • bins (int_scalars, default=10) – The number of equal-size bins to use (default: 10)

  • range ((min_val, max_val), optional) – The range of the values to count. Values outside of this range are dropped. By default, all values are counted.

Returns:

The number of values present in each bin and the bin edges

Return type:

(pdarray, Union[pdarray, int64 or float64])

Raises:
  • TypeError – Raised if the parameter is not a pdarray or if bins is not an int.

  • ValueError – Raised if bins < 1

  • NotImplementedError – Raised if pdarray dtype is bool or uint8

Notes

The bins are evenly spaced in the interval [pda.min(), pda.max()]. If range parameter is provided, the interval is [range[0], range[1]].

Examples

>>> import arkouda as ak
>>> import matplotlib.pyplot as plt
>>> A = ak.arange(0, 10, 1)
>>> nbins = 3
>>> h, b = ak.histogram(A, bins=nbins)
>>> h
array([3 3 4])
>>> b
array([0.00000000... 3.00000000... 6.00000000... 9.00000000...])

To plot, export the left edges and the histogram to NumPy >>> b_np = b.to_ndarray() >>> import numpy as np >>> b_widths = np.diff(b_np) >>> plt.bar(b_np[:-1], h.to_ndarray(), width=b_widths, align=’edge’, edgecolor=’black’) <BarContainer object of 3 artists> >>> plt.show() # doctest: +SKIP

arkouda.numpy.histogram2d(x: arkouda.numpy.pdarrayclass.pdarray, y: arkouda.numpy.pdarrayclass.pdarray, bins: arkouda.numpy.dtypes.int_scalars | Sequence[arkouda.numpy.dtypes.int_scalars] = 10, range: Tuple[Tuple[arkouda.numpy.dtypes.numeric_scalars, arkouda.numpy.dtypes.numeric_scalars], Tuple[arkouda.numpy.dtypes.numeric_scalars, arkouda.numpy.dtypes.numeric_scalars]] | None = None) Tuple[arkouda.numpy.pdarrayclass.pdarray, arkouda.numpy.pdarrayclass.pdarray, arkouda.numpy.pdarrayclass.pdarray][source]

Compute the bi-dimensional histogram of two data samples with evenly spaced bins.

Parameters:
  • x (pdarray) – A pdarray containing the x coordinates of the points to be histogrammed.

  • y (pdarray) – A pdarray containing the y coordinates of the points to be histogrammed.

  • bins (int_scalars or [int, int], default=10) – The number of equal-size bins to use. If int, the number of bins for the two dimensions (nx=ny=bins). If [int, int], the number of bins in each dimension (nx, ny = bins). Defaults to 10

  • range (((x_min, x_max), (y_min, y_max)), optional) – The ranges of the values in x and y to count. Values outside of these ranges are dropped. By default, all values are counted.

Returns:

histpdarray

shape(nx, ny) The bi-dimensional histogram of samples x and y. Values in x are histogrammed along the first dimension and values in y are histogrammed along the second dimension.

x_edgespdarray

The bin edges along the first dimension.

y_edgespdarray

The bin edges along the second dimension.

Return type:

Tuple[pdarray, pdarray, pdarray]

Raises:
  • TypeError – Raised if x or y parameters are not pdarrays or if bins is not an int or (int, int).

  • ValueError – Raised if bins < 1

  • NotImplementedError – Raised if pdarray dtype is bool or uint8

See also

histogram

Notes

The x bins are evenly spaced in the interval [x.min(), x.max()] and y bins are evenly spaced in the interval [y.min(), y.max()]. If range parameter is provided, the intervals are given by range[0] for x and range[1] for y..

Examples

>>> import arkouda as ak
>>> x = ak.arange(0, 10, 1)
>>> y = ak.arange(9, -1, -1)
>>> nbins = 3
>>> h, x_edges, y_edges = ak.histogram2d(x, y, bins=nbins)
>>> h
array([array([0.00000000... 0.00000000... 3.00000000...])
       array([0.00000000... 2.00000000... 1.00000000...])
       array([3.00000000... 1.00000000... 0.00000000...])])
>>> x_edges
array([0.00000000... 3.00000000... 6.00000000... 9.00000000...])
>>> y_edges
array([0.00000000... 3.00000000... 6.00000000... 9.00000000...])
arkouda.numpy.histogramdd(sample: Sequence[arkouda.numpy.pdarrayclass.pdarray], bins: arkouda.numpy.dtypes.int_scalars | Sequence[arkouda.numpy.dtypes.int_scalars] = 10, range: Sequence[Tuple[arkouda.numpy.dtypes.numeric_scalars, arkouda.numpy.dtypes.numeric_scalars] | None] | None = None) Tuple[arkouda.numpy.pdarrayclass.pdarray, Sequence[arkouda.numpy.pdarrayclass.pdarray]][source]

Compute the multidimensional histogram of data in sample with evenly spaced bins.

Parameters:
  • sample (Sequence of pdarray) – A sequence of pdarrays containing the coordinates of the points to be histogrammed.

  • bins (int_scalars or Sequence of int_scalars, default=10) – The number of equal-size bins to use. If int, the number of bins for all dimensions (nx=ny=…=bins). If [int, int, …], the number of bins in each dimension (nx, ny, … = bins). Defaults to 10

  • range (Sequence[optional (min_val, max_val)], optional) – The ranges of the values to count for each array in sample. Values outside of these ranges are dropped. By default, all values are counted.

Returns:

histpdarray

shape(nx, ny, …, nd) The multidimensional histogram of pdarrays in sample. Values in first pdarray are histogrammed along the first dimension. Values in second pdarray are histogrammed along the second dimension and so on.

edgesList[pdarray]

A list of pdarrays containing the bin edges for each dimension.

Return type:

Tuple[pdarray, Sequence[pdarray]]

Raises:
  • ValueError – Raised if bins < 1

  • NotImplementedError – Raised if pdarray dtype is bool or uint8

See also

histogram

Notes

The bins for each dimension, m, are evenly spaced in the interval [m.min(), m.max()] or in the inverval determined by range[dimension], if provided.

Examples

>>> import arkouda as ak
>>> x = ak.arange(0, 10, 1)
>>> y = ak.arange(9, -1, -1)
>>> z = ak.where(x % 2 == 0, x, y)
>>> h, edges = ak.histogramdd((x, y,z), bins=(2,2,3))
>>> h
array([array([array([0.00000000... 0.00000000... 0.00000000...])
    array([2.00000000... 1.00000000... 2.00000000...])])
    array([array([2.00000000... 1.00000000... 2.00000000...])
    array([0.00000000... 0.00000000... 0.00000000...])])])
>>> edges
[array([0.00000000... 4.5 9.00000000...]),
    array([0.00000000... 4.5 9.00000000...]),
    array([0.00000000... 2.66666666... 5.33333333... 8.00000000...])]
arkouda.numpy.hstack(tup: Sequence[arkouda.numpy.pdarrayclass.pdarray], *, dtype: str | type | None = None, casting: Literal['no', 'equiv', 'safe', 'same_kind', 'unsafe'] = 'same_kind') arkouda.numpy.pdarrayclass.pdarray[source]

Stack arrays in sequence horizontally (column wise).

This is equivalent to concatenation along the second axis, except for 1-D arrays where it concatenates along the first axis. Rebuilds arrays divided by hsplit.

This function makes most sense for arrays with up to 3 dimensions. For instance, for pixel-data with a height (first axis), width (second axis), and r/g/b channels (third axis). The functions concatenate, stack and block provide more general stacking and concatenation operations.

Parameters:
  • tup (sequence of pdarray) – The arrays must have the same shape along all but the second axis, except 1-D arrays which can be any length. In the case of a single array_like input, it will be treated as a sequence of arrays; i.e., each element along the zeroth axis is treated as a separate array.

  • dtype (str or type, optional) – If provided, the destination array will have this type.

  • casting ({‘no’, ‘equiv’, ‘safe’, ‘same_kind’, ‘unsafe’}, optional) – Controls what kind of data casting may occur. Defaults to ‘same_kind’. Currently unused.

Returns:

The array formed by stacking the given arrays.

Return type:

pdarray

See also

concatenate, stack, block, vstack, dstack, column_stack, hsplit, unstack

Examples

>>> import arkouda as ak
>>> a = ak.array([1, 2, 3])
>>> b = ak.array([4, 5, 6])
>>> ak.hstack((a, b))
array([1 2 3 4 5 6])
>>> a = ak.array([[1],[2],[3]])
>>> b = ak.array([[4],[5],[6]])
>>> ak.hstack((a, b))
array([array([1 4]) array([2 5]) array([3 6])])
class arkouda.numpy.iinfo

iinfo(type)

Machine limits for integer types.

bits

The number of bits occupied by the type.

Type:

int

dtype

Returns the dtype for which iinfo returns information.

Type:

dtype

min

The smallest integer expressible by the type.

Type:

int

max

The largest integer expressible by the type.

Type:

int

Parameters:

int_type (integer type, dtype, or instance) – The kind of integer data type to get information about.

See also

finfo

The equivalent for floating point data types.

Examples

With types:

>>> import numpy as np
>>> ii16 = np.iinfo(np.int16)
>>> ii16.min
-32768
>>> ii16.max
32767
>>> ii32 = np.iinfo(np.int32)
>>> ii32.min
-2147483648
>>> ii32.max
2147483647

With instances:

>>> ii32 = np.iinfo(np.int32(10))
>>> ii32.min
-2147483648
>>> ii32.max
2147483647
property max

Maximum value of given dtype.

property min

Minimum value of given dtype.

arkouda.numpy.in1d(A: arkouda.pandas.groupbyclass.groupable, B: arkouda.pandas.groupbyclass.groupable, assume_unique: bool = False, symmetric: bool = False, invert: bool = False) arkouda.pandas.groupbyclass.groupable[source]

Test whether each element of a 1-D array is also present in a second array.

Returns a boolean array the same length as A that is True where an element of A is in B and False otherwise.

Supports multi-level, i.e. test if rows of a are in the set of rows of b. But note that multi-dimensional pdarrays are not supported.

Parameters:
  • A (list of pdarrays, pdarray, Strings, or Categorical) – Entries will be tested for membership in B

  • B (list of pdarrays, pdarray, Strings, or Categorical) – The set of elements in which to test membership

  • assume_unique (bool, optional, defaults to False) – If true, assume rows of a and b are each unique and sorted. By default, sort and unique them explicitly.

  • symmetric (bool, optional, defaults to False) – Return in1d(A, B), in1d(B, A) when A and B are single items.

  • invert (bool, optional, defaults to False) – If True, the values in the returned array are inverted (that is, False where an element of A is in B and True otherwise). Default is False. ak.in1d(a, b, invert=True) is equivalent to (but is faster than) ~ak.in1d(a, b).

Returns:

True for each row in a that is contained in b

Return type:

groupable

Raises:
  • TypeError – Raised if either A or B is not a pdarray, Strings, or Categorical object, or if both are pdarrays and either has rank > 1, or if invert is not a bool

  • RuntimeError – Raised if the dtype of either array is not supported

Examples

>>> import arkouda as ak
>>> ak.in1d(ak.array([-1, 0, 1]), ak.array([-2, 0, 2]))
array([False True False])
>>> ak.in1d(ak.array(['one','two']),ak.array(['two', 'three','four','five']))
array([False True])

Notes

in1d can be considered as an element-wise function version of the python keyword in, for 1-D sequences. in1d(a, b) is logically equivalent to ak.array([item in b for item in a]), but is much faster and scales to arbitrarily large a.

ak.in1d is not supported for bool or float64 pdarrays

arkouda.numpy.in1d_intervals(vals, intervals, symmetric=False)[source]

Test each value for membership in any of a set of half-open (pythonic) intervals.

Parameters:
  • vals (pdarray(int, float)) – Values to test for membership in intervals

  • intervals (2-tuple of pdarrays) – Non-overlapping, half-open intervals, as a tuple of (lower_bounds_inclusive, upper_bounds_exclusive)

  • symmetric (bool) – If True, also return boolean pdarray indicating which intervals contained one or more query values.

Returns:

  • pdarray(bool) – Array of same length as <vals>, True if corresponding value is included in any of the ranges defined by (low[i], high[i]) inclusive.

  • pdarray(bool) (if symmetric=True) – Array of same length as number of intervals, True if corresponding interval contains any of the values in <vals>.

Notes

First return array is equivalent to the following:

((vals >= intervals[0][0]) & (vals < intervals[1][0])) | ((vals >= intervals[0][1]) & (vals < intervals[1][1])) | … ((vals >= intervals[0][-1]) & (vals < intervals[1][-1]))

But much faster when testing many ranges.

Second (optional) return array is equivalent to:

((intervals[0] <= vals[0]) & (intervals[1] > vals[0])) | ((intervals[0] <= vals[1]) & (intervals[1] > vals[1])) | … ((intervals[0] <= vals[-1]) & (intervals[1] > vals[-1]))

But much faster when vals is non-trivial size.

arkouda.numpy.indexof1d(query: arkouda.pandas.groupbyclass.groupable, space: arkouda.pandas.groupbyclass.groupable) arkouda.numpy.pdarrayclass.pdarray[source]

Return indices of query items in a search list of items. Items not found will be excluded. When duplicate terms are present in search space return indices of all occurrences.

Parameters:
  • query ((sequence of) pdarray or Strings or Categorical) – The items to search for. If multiple arrays, each “row” is an item.

  • space ((sequence of) pdarray or Strings or Categorical) – The set of items in which to search. Must have same shape/dtype as query.

Returns:

For each item in query that is found in space, its index in space.

Return type:

pdarray

Notes

This is an alias of ak.find(query, space, all_occurrences=True, remove_missing=True).values

Examples

>>> import arkouda as ak
>>> select_from = ak.arange(10)
>>> query = select_from[ak.randint(0, select_from.size, 20, seed=10)]
>>> space = select_from[ak.randint(0, select_from.size, 20, seed=11)]

remove some values to ensure that query has entries which don’t appear in space

>>> space = space[space != 9]
>>> space = space[space != 3]
>>> ak.indexof1d(query, space)
array([0 4 1 3 10 2 6 12 13 5 7 8 9 14 5 7 11 15 5 7 0 4])
Raises:
  • TypeError – Raised if either query or space is not a pdarray, Strings, or Categorical object

  • RuntimeError – Raised if the dtype of either array is not supported

class arkouda.numpy.inexact

Bases: numpy.number

Abstract base class of all numeric scalar types with a (potentially)

inexact representation of the values in its range, such as floating-point numbers.

arkouda.numpy.inf: float
class arkouda.numpy.int16

Bases: numpy.signedinteger

Signed integer type, compatible with C short.

Character code:

'h'

Canonical name:

numpy.short

Alias on this platform (Linux x86_64):

numpy.int16: 16-bit signed integer (-32_768 to 32_767).

bit_count(/)

int16.bit_count() -> int

Computes the number of 1-bits in the absolute value of the input. Analogous to the builtin int.bit_count or popcount in C++.

>>> np.int16(127).bit_count()
7
>>> np.int16(-127).bit_count()
7
class arkouda.numpy.int32

Bases: numpy.signedinteger

Signed integer type, compatible with C int.

Character code:

'i'

Canonical name:

numpy.intc

Alias on this platform (Linux x86_64):

numpy.int32: 32-bit signed integer (-2_147_483_648 to 2_147_483_647).

bit_count(/)

int32.bit_count() -> int

Computes the number of 1-bits in the absolute value of the input. Analogous to the builtin int.bit_count or popcount in C++.

>>> np.int32(127).bit_count()
7
>>> np.int32(-127).bit_count()
7
class arkouda.numpy.int64

Bases: numpy.signedinteger

Default signed integer type, 64bit on 64bit systems and 32bit on 32bit

systems.

Character code:

'l'

Canonical name:

numpy.int_

Alias on this platform (Linux x86_64):

numpy.int64: 64-bit signed integer (-9_223_372_036_854_775_808 to 9_223_372_036_854_775_807).

Alias on this platform (Linux x86_64):

numpy.intp: Signed integer large enough to fit pointer, compatible with C intptr_t.

bit_count(/)

int64.bit_count() -> int

Computes the number of 1-bits in the absolute value of the input. Analogous to the builtin int.bit_count or popcount in C++.

>>> np.int64(127).bit_count()
7
>>> np.int64(-127).bit_count()
7
class arkouda.numpy.int8

Bases: numpy.signedinteger

Signed integer type, compatible with C char.

Character code:

'b'

Canonical name:

numpy.byte

Alias on this platform (Linux x86_64):

numpy.int8: 8-bit signed integer (-128 to 127).

bit_count(/)

int8.bit_count() -> int

Computes the number of 1-bits in the absolute value of the input. Analogous to the builtin int.bit_count or popcount in C++.

>>> np.int8(127).bit_count()
7
>>> np.int8(-127).bit_count()
7
class arkouda.numpy.intTypes

Build an immutable unordered collection of unique elements.

copy()

Return a shallow copy of a set.

difference(*others)

Return a new set with elements in the set that are not in the others.

intersection(*others)

Return a new set with elements common to the set and all others.

isdisjoint(other, /)

Return True if two sets have a null intersection.

issubset(other, /)

Report whether another set contains this set.

issuperset(other, /)

Report whether this set contains another set.

symmetric_difference(other, /)

Return a new set with elements in either the set or other but not both.

union(*others)

Return a new set with elements from the set and all others.

class arkouda.numpy.int_scalars

Bases: _NotIterable

Mixin to prevent iteration, without being compatible with Iterable.

That is, we could do:

def __iter__(self): raise TypeError()

But this would make users of this mixin duck type-compatible with collections.abc.Iterable - isinstance(foo, Iterable) would be True.

Luckily, we can instead prevent iteration by setting __iter__ to None, which is treated specially.

copy_with(params)
class arkouda.numpy.intc

Bases: numpy.signedinteger

Signed integer type, compatible with C int.

Character code:

'i'

Canonical name:

numpy.intc

Alias on this platform (Linux x86_64):

numpy.int32: 32-bit signed integer (-2_147_483_648 to 2_147_483_647).

bit_count(/)

int32.bit_count() -> int

Computes the number of 1-bits in the absolute value of the input. Analogous to the builtin int.bit_count or popcount in C++.

>>> np.int32(127).bit_count()
7
>>> np.int32(-127).bit_count()
7
arkouda.numpy.intersect1d(ar1: arkouda.pandas.groupbyclass.groupable, ar2: arkouda.pandas.groupbyclass.groupable, assume_unique: bool = False) arkouda.numpy.pdarrayclass.pdarray | arkouda.pandas.groupbyclass.groupable[source]

Find the intersection of two arrays.

Return the sorted, unique values that are in both of the input arrays.

Parameters:
Returns:

Sorted 1D array/List of sorted pdarrays of common and unique elements.

Return type:

pdarray/groupable

Raises:
  • TypeError – Raised if either ar1 or ar2 is not a groupable

  • RuntimeError – Raised if the dtype of either pdarray is not supported

Examples

>>> import arkouda as ak

1D Example >>> ak.intersect1d(ak.array([1, 3, 4, 3]), ak.array([3, 1, 2, 1])) array([1 3])

Multi-Array Example >>> a = ak.arange(5) >>> b = ak.array([1, 5, 3, 4, 2]) >>> c = ak.array([1, 4, 3, 2, 5]) >>> d = ak.array([1, 2, 3, 5, 4]) >>> multia = [a, a, a] >>> multib = [b, c, d] >>> ak.intersect1d(multia, multib) [array([1 3]), array([1 3]), array([1 3])]

arkouda.numpy.interval_lookup(keys, values, arguments, fillvalue=-1, tiebreak=None, hierarchical=False)[source]

Apply a function defined over intervals to an array of arguments.

Parameters:
  • keys (2-tuple of (sequences of) pdarrays) – Tuple of closed intervals expressed as (lower_bounds_inclusive, upper_bounds_inclusive). Must have same dtype(s) as vals.

  • values (pdarray) – Function value to return for each entry in keys.

  • arguments ((sequences of) pdarray) – Values to search for in intervals. If multiple arrays, each “row” is an item.

  • fillvalue (scalar) – Default value to return when argument is not in any interval.

  • tiebreak ((optional) pdarray, numeric) – When an argument is present in more than one key interval, the interval with the lowest tiebreak value will be chosen. If no tiebreak is given, the first valid key interval will be chosen.

Returns:

Value of function corresponding to the keys interval containing each argument, or fillvalue if argument not in any interval.

Return type:

pdarray

class arkouda.numpy.intp

Bases: numpy.signedinteger

Default signed integer type, 64bit on 64bit systems and 32bit on 32bit

systems.

Character code:

'l'

Canonical name:

numpy.int_

Alias on this platform (Linux x86_64):

numpy.int64: 64-bit signed integer (-9_223_372_036_854_775_808 to 9_223_372_036_854_775_807).

Alias on this platform (Linux x86_64):

numpy.intp: Signed integer large enough to fit pointer, compatible with C intptr_t.

bit_count(/)

int64.bit_count() -> int

Computes the number of 1-bits in the absolute value of the input. Analogous to the builtin int.bit_count or popcount in C++.

>>> np.int64(127).bit_count()
7
>>> np.int64(-127).bit_count()
7
arkouda.numpy.isSupportedBool(num)[source]

Deprecated alias for is_supported_bool().

This function exists for backward compatibility only. Use is_supported_bool() instead.

Parameters:

num (object) – A scalar value to test.

Returns:

True if num is an arkouda-supported boolean dtype, otherwise False.

Return type:

bool

See also

is_supported_bool

Preferred replacement.

arkouda.numpy.isSupportedDType(num)[source]

Deprecated alias for is_supported_dtype().

This function exists for backward compatibility only. Use is_supported_dtype() instead.

Parameters:

num (object) – A scalar value to test.

Returns:

True if num is an arkouda-supported dtype, otherwise False.

Return type:

bool

See also

is_supported_dtype

Preferred replacement.

arkouda.numpy.isSupportedFloat(num)[source]

Deprecated alias for is_supported_float().

This function exists for backward compatibility only. Use is_supported_float() instead.

Parameters:

num (object) – A scalar value to test.

Returns:

True if num is an arkouda-supported float dtype, otherwise False.

Return type:

bool

See also

is_supported_float

Preferred replacement.

arkouda.numpy.isSupportedInt(num)[source]

Deprecated alias for is_supported_int().

This function exists for backward compatibility only. Use is_supported_int() instead.

Parameters:

num (object) – A scalar value to test.

Returns:

True if num is an arkouda-supported integer dtype, otherwise False.

Return type:

bool

See also

is_supported_int

Preferred replacement.

arkouda.numpy.isSupportedNumber(num)[source]

Deprecated alias for is_supported_number().

This function exists for backward compatibility only. Use is_supported_number() instead.

Parameters:

num (object) – A scalar value to test.

Returns:

True if num is an arkouda-supported numeric dtype, otherwise False.

Return type:

bool

See also

is_supported_number

Preferred replacement.

arkouda.numpy.is_cosorted(arrays)[source]

Return True iff the arrays are cosorted.

Return True iff the arrays are cosorted, i.e., if the arrays were columns in a table then the rows are sorted.

Parameters:

arrays (list-like of pdarrays) – Arrays to check for cosortedness

Returns:

True iff arrays are cosorted.

Return type:

bool

Raises:
  • ValueError – Raised if arrays are not the same length

  • TypeError – Raised if arrays is not a list-like of pdarrays

arkouda.numpy.is_registered(name: str, as_component: bool = False) bool[source]

Determine if the provided name is associated with a registered Arkouda object.

This function checks if the name is found in the registry of objects, and optionally checks if it is registered as a component of a registered object.

Parameters:
  • name (str) – The name to check for in the registry.

  • as_component (bool, default=False) – When True, the function checks if the name is registered as a component of a registered object (rather than as a standalone object).

Returns:

True if the name is found in the registry, False otherwise.

Return type:

bool

Raises:

KeyError – If the registry query encounters an issue (e.g., invalid registry data or access issues).

Examples

>>> import arkouda as ak

Check if a name is registered as an object >>> obj = ak.array([1, 2, 3]) >>> registered_obj = obj.register(“my_array”) >>> result = ak.is_registered(“my_array”) >>> print(result) True >>> registered_obj.unregister()

Check if a name is registered as a component >>> result = ak.is_registered(“my_component”, as_component=True) >>> print(result) False

arkouda.numpy.is_supported_bool(num) TypeGuard[bool_scalars][source]

Whether a scalar is an arkouda supported boolean dtype.

Parameters:

num (object) – A scalar.

Returns:

True if scalar is an instance of an arkouda supported boolean dtype, else False.

Return type:

bool

Examples

>>> import arkouda as ak
>>> ak.is_supported_bool("True")
False
>>> ak.is_supported_bool(True)
True
arkouda.numpy.is_supported_dtype(scalar: object) bool[source]

Whether a scalar is an arkouda supported dtype.

Parameters:

scalar (object)

Returns:

True if scalar is an instance of an arkouda supported dtype, else False.

Return type:

builtins.bool

Examples

>>> import arkouda as ak
>>> ak.is_supported_dtype(ak.int64(64))
True
>>> ak.is_supported_dtype(np.complex128(1+2j))
False
arkouda.numpy.is_supported_float(num) TypeGuard[float_scalars][source]

Whether a scalar is an arkouda supported float dtype.

Parameters:

num (object) – A scalar.

Returns:

True if scalar is an instance of an arkouda supported float dtype, else False.

Return type:

bool

Examples

>>> import arkouda as ak
>>> ak.is_supported_float(56)
False
>>> ak.is_supported_float(56.7)
True
arkouda.numpy.is_supported_int(num) TypeGuard[int_scalars][source]

Whether a scalar is an arkouda supported integer dtype.

Parameters:

num (object) – A scalar.

Returns:

True if scalar is an instance of an arkouda supported integer dtype, else False.

Return type:

bool

Examples

>>> import arkouda as ak
>>> ak.is_supported_int(79)
True
>>> ak.is_supported_int(54.9)
False
arkouda.numpy.is_supported_number(num) TypeGuard[numeric_scalars][source]

Whether a scalar is an arkouda supported numeric dtype.

Parameters:

num (object) – A scalar.

Returns:

True if scalar is an instance of an arkouda supported numeric dtype, else False.

Return type:

bool

Examples

>>> import arkouda as ak
>>> ak.is_supported_number(45.9)
True
>>> ak.is_supported_number("string")
False
arkouda.numpy.isfinite(pda: arkouda.numpy.pdarrayclass.pdarray) arkouda.numpy.pdarrayclass.pdarray[source]

Return the element-wise isfinite check applied to the array.

Parameters:

pda (pdarray)

Returns:

A pdarray containing boolean values indicating whether the input array elements are finite

Return type:

pdarray

Raises:
  • TypeError – Raised if the parameter is not a pdarray

  • RuntimeError – if the underlying pdarray is not float-based

Examples

>>> import arkouda as ak
>>> ak.isfinite(ak.array([1.0, 2.0, ak.inf]))
array([True True False])
arkouda.numpy.isinf(pda: arkouda.numpy.pdarrayclass.pdarray) arkouda.numpy.pdarrayclass.pdarray[source]

Return the element-wise isinf check applied to the array.

Parameters:

pda (pdarray)

Returns:

A pdarray containing boolean values indicating whether the input array elements are infinite (positive or negative)

Return type:

pdarray

Raises:
  • TypeError – Raised if the parameter is not a pdarray

  • RuntimeError – if the underlying pdarray is not float-based

Examples

>>> import arkouda as ak
>>> ak.isinf(ak.array([1.0, 2.0, ak.inf]))
array([False False True])
arkouda.numpy.isnan(pda: arkouda.numpy.pdarrayclass.pdarray) arkouda.numpy.pdarrayclass.pdarray[source]

Return the element-wise isnan check applied to the array.

Parameters:

pda (pdarray)

Returns:

A pdarray containing boolean values indicating whether the input array elements are NaN

Return type:

pdarray

Raises:
  • TypeError – Raised if the parameter is not a pdarray

  • RuntimeError – if the underlying pdarray is not one of float, int, uint or bool

Examples

>>> import arkouda as ak
>>> ak.isnan(ak.array([1.0, 2.0, np.log(-1)]))
array([False False True])
arkouda.numpy.isnumeric(pda) arkouda.numpy.pdarrayclass.pdarray[source]

Return a boolean pdarray where index i indicates whether string i of the Strings has all numeric characters. There are 1922 unicode characters that qualify as numeric, including the digits 0 through 9, superscripts and subscripted digits, special characters with the digits encircled or enclosed in parens, “vulgar fractions,” and more.

Returns:

True for elements that are numerics, False otherwise

Return type:

pdarray

Raises:
  • RuntimeError – Raised if there is a server-side error thrown

  • TypeError – Raised if the input is not a Strings type

Examples

>>> import arkouda as ak
>>> not_numeric = ak.array([f'Strings {i}' for i in range(3)])
>>> numeric = ak.array([f'12{i}' for i in range(3)])
>>> strings = ak.concatenate([not_numeric, numeric])
>>> strings
array(['Strings 0', 'Strings 1', 'Strings 2', '120', '121', '122'])
>>> ak.isnumeric(strings)
array([False False False True True True])

Special Character Examples

>>> special_strings = ak.array(["3.14", "0", "²", "2³₇", "2³x₇"])
>>> special_strings
array(['3.14', '0', '²', '2³₇', '2³x₇'])
>>> ak.isnumeric(special_strings)
array([False True True True False])
arkouda.numpy.isscalar(element)

Returns True if the type of element is a scalar type.

Parameters:

element (any) – Input argument, can be of any type and shape.

Returns:

val – True if element is a scalar type, False if it is not.

Return type:

bool

See also

ndim

Get the number of dimensions of an array

Notes

If you need a stricter way to identify a numerical scalar, use isinstance(x, numbers.Number), as that returns False for most non-numerical elements such as strings.

In most cases np.ndim(x) == 0 should be used instead of this function, as that will also return true for 0d arrays. This is how numpy overloads functions in the style of the dx arguments to gradient and the bins argument to histogram. Some key differences:

x

isscalar(x)

np.ndim(x) == 0

PEP 3141 numeric objects (including builtins)

True

True

builtin string and buffer objects

True

True

other builtin objects, like pathlib.Path, Exception, the result of re.compile

False

True

third-party objects like matplotlib.figure.Figure

False

True

zero-dimensional numpy arrays

False

True

other numpy arrays

False

False

list, tuple, and other sequence objects

False

False

Examples

>>> import numpy as np
>>> np.isscalar(3.1)
True
>>> np.isscalar(np.array(3.1))
False
>>> np.isscalar([3.1])
False
>>> np.isscalar(False)
True
>>> np.isscalar('numpy')
True

NumPy supports PEP 3141 numbers:

>>> from fractions import Fraction
>>> np.isscalar(Fraction(5, 17))
True
>>> from numbers import Number
>>> np.isscalar(Number())
True
arkouda.numpy.issubdtype(arg1, arg2)

Returns True if first argument is a typecode lower/equal in type hierarchy.

This is like the builtin issubclass(), but for dtypes.

Parameters:
  • arg1 (dtype_like) – dtype or object coercible to one

  • arg2 (dtype_like) – dtype or object coercible to one

Returns:

out

Return type:

bool

See also

arrays.scalars

Overview of the numpy type hierarchy.

Examples

issubdtype can be used to check the type of arrays:

>>> ints = np.array([1, 2, 3], dtype=np.int32)
>>> np.issubdtype(ints.dtype, np.integer)
True
>>> np.issubdtype(ints.dtype, np.floating)
False
>>> floats = np.array([1, 2, 3], dtype=np.float32)
>>> np.issubdtype(floats.dtype, np.integer)
False
>>> np.issubdtype(floats.dtype, np.floating)
True

Similar types of different sizes are not subdtypes of each other:

>>> np.issubdtype(np.float64, np.float32)
False
>>> np.issubdtype(np.float32, np.float64)
False

but both are subtypes of floating:

>>> np.issubdtype(np.float64, np.floating)
True
>>> np.issubdtype(np.float32, np.floating)
True

For convenience, dtype-like objects are allowed too:

>>> np.issubdtype('S1', np.bytes_)
True
>>> np.issubdtype('i4', np.signedinteger)
True
arkouda.numpy.left_align(left, right)[source]

Map two arrays of sparse identifiers to the 0-up index.

Map two arrays of sparse identifiers to the 0-up index set implied by the left array, discarding values from right that do not appear in left.

arkouda.numpy.linspace(start: arkouda.numpy.dtypes.numeric_scalars | arkouda.numpy.pdarrayclass.pdarray, stop: arkouda.numpy.dtypes.numeric_scalars | arkouda.numpy.pdarrayclass.pdarray, num: arkouda.numpy.dtypes.int_scalars = 50, endpoint: None | bool = True, dtype: type | None = float64, axis: arkouda.numpy.dtypes.int_scalars = 0) arkouda.numpy.pdarrayclass.pdarray[source]

Return evenly spaced numbers over a specified interval.

Returns num evenly spaced samples, calculated over the interval [start, stop].

The endpoint of the interval can optionally be excluded.

Parameters:
  • start (Union[numeric_scalars, pdarray]) – The starting value of the sequence.

  • stop (Union[numeric_scalars, pdarray]) – The end value of the sequence, unless endpoint is set to False. In that case, the sequence consists of all but the last of num + 1 evenly spaced samples, so that stop is excluded. Note that the step size changes when endpoint is False.

  • num (int, optional) – Number of samples to generate. Default is 50. Must be non-negative.

  • endpoint (bool, optional) – If True, stop is the last sample. Otherwise, it is not included. Default is True.

  • dtype (dtype, optional) – Allowed for compatibility with numpy linspace, but anything entered is ignored. The output is always ak.float64.

  • axis (int, optional) – The axis in the result to store the samples. Relevant only if start or stop are array-like. By default (0), the samples will be along a new axis inserted at the beginning. Use -1 to get an axis at the end.

Returns:

There are num equally spaced samples in the closed interval [start, stop] or the half-open interval [start, stop) (depending on whether endpoint is True or False).

Return type:

pdarray

Raises:
  • TypeError – Raised if start or stop is not a float or a pdarray, or if num is not an int, or if endpoint is not a bool, or if dtype is anything other than None or float64, or axis is not an integer.

  • ValueError – Raised if axis is not a valid axis for the given data.

Examples

>>> import arkouda as ak
>>> ak.linspace(0,1,3)
array([0.00000000000000000 0.5 1.00000000000000000])
>>> ak.linspace(1,0,3)
array([1.00000000000000000 0.5 0.00000000000000000])
>>> ak.linspace(0,1,3,endpoint=False)
array([0.00000000000000000 0.33333333333333331 0.66666666666666663])
>>> ak.linspace(0,ak.array([2,3]),3)
array([array([0.00000000000000000 0.00000000000000000])
    array([1.00000000000000000 1.5]) array([2.00000000000000000 3.00000000000000000])])
>>> ak.linspace(ak.array([0,1]),3,3)
array([array([0.00000000000000000 1.00000000000000000])
    array([1.5 2.00000000000000000]) array([3.00000000000000000 3.00000000000000000])])
>>> ak.linspace(ak.array([0,1]),ak.array([2,3]),3)
array([array([0.00000000000000000 1.00000000000000000])
    array([1.00000000000000000 2.00000000000000000])
    array([2.00000000000000000 3.00000000000000000])])
arkouda.numpy.log(pda: arkouda.numpy.pdarrayclass.pdarray) arkouda.numpy.pdarrayclass.pdarray[source]

Return the element-wise natural log of the array.

Parameters:

pda (pdarray)

Returns:

A pdarray containing natural log values of the input array elements

Return type:

pdarray

Raises:

TypeError – Raised if the parameter is not a pdarray

Notes

Logarithms with other bases can be computed as follows:

Examples

>>> import arkouda as ak
>>> A = ak.array([1, 10, 100])

Natural log >>> ak.log(A) array([0.00000000… 2.30258509… 4.60517018…])

Log base 10 >>> ak.log(A) / np.log(10) array([0.00000000… 1.00000000… 2.00000000…])

Log base 2 >>> ak.log(A) / np.log(2) array([0.00000000… 3.32192809… 6.64385618…])

arkouda.numpy.log10(pda: arkouda.numpy.pdarrayclass.pdarray) arkouda.numpy.pdarrayclass.pdarray[source]

Return the element-wise base 10 log of the array.

Parameters:

pda (pdarray) – array to compute on

Returns:

pdarray containing base 10 log values of the input array elements

Return type:

pdarray

Examples

>>> import arkouda as ak
>>> a = ak.arange(1,5)
>>> ak.log10(a)
array([0.00000000... 0.30102999... 0.47712125... 0.60205999...])
arkouda.numpy.log1p(pda: arkouda.numpy.pdarrayclass.pdarray) arkouda.numpy.pdarrayclass.pdarray[source]

Return the element-wise natural log of one plus the array.

Parameters:

pda (pdarray) – array to compute on

Returns:

pdarray containing natural log values of the input array elements, adding one before taking the log

Return type:

pdarray

Examples

>>> import arkouda as ak
>>> ak.log1p(ak.arange(1,5))
array([0.69314718... 1.09861228... 1.38629436... 1.60943791...])
arkouda.numpy.log2(pda: arkouda.numpy.pdarrayclass.pdarray) arkouda.numpy.pdarrayclass.pdarray[source]

Return the element-wise base 2 log of the array.

Parameters:

pda (pdarray) – array to compute on

Returns:

pdarray containing base 2 log values of the input array elements

Return type:

pdarray

Examples

>>> import arkouda as ak
>>> a = ak.arange(1,5)
>>> ak.log2(a)
array([0.00000000... 1.00000000... 1.58496250... 2.00000000...])
arkouda.numpy.logical_not(x: pdarray) pdarray[source]
arkouda.numpy.logical_not(x: arkouda.numpy.dtypes.numeric_scalars) arkouda.numpy.dtypes.bool_

Compute the truth value of NOT x element-wise.

This function returns a boolean pdarray where each element is the logical negation of the corresponding element in x. For boolean arrays, this is equivalent to applying the unary ~ operator. For numeric arrays, zero is treated as False and non-zero as True.

Parameters:

x (pdarray) – Input array on which to compute element-wise logical NOT.

Returns:

A boolean pdarray with the same shape as x containing the result of the NOT operation applied element-wise.

Return type:

pdarray

Notes

This is a simplified version of numpy.logical_not(). It currently does not support keyword arguments such as out or where, and always allocates a new result array.

Examples

>>> import arkouda as ak
>>> x = ak.array([True, False, True])
>>> ak.logical_not(x)
array([False  True False])
>>> y = ak.array([0, 1, 2])
>>> ak.logical_not(y)
array([True False False])
arkouda.numpy.logspace(start: arkouda.numpy.dtypes.numeric_scalars | arkouda.numpy.pdarrayclass.pdarray, stop: arkouda.numpy.dtypes.numeric_scalars | arkouda.numpy.pdarrayclass.pdarray, num: arkouda.numpy.dtypes.int_scalars = 50, base: arkouda.numpy.dtypes.numeric_scalars = 10.0, endpoint: None | bool = True, dtype: type | None = float64, axis: None | arkouda.numpy.dtypes.int_scalars = 0) arkouda.numpy.pdarrayclass.pdarray[source]

Create a pdarray of numbers evenly spaced on a log scale.

Parameters:
  • start (Union[numeric_scalars, pdarray]) – The starting value of the sequence.

  • stop (Union[numeric_scalars, pdarray]) – The end value of the sequence, unless endpoint is set to False. In that case, the sequence consists of all but the last of num + 1 evenly spaced samples, so that stop is excluded. Note that the step size changes when endpoint is False.

  • num (int, optional) – Number of samples to generate. Default is 50. Must be non-negative.

  • base (numeric_scalars, optional) – the base of the log space, defaults to 10.0.

  • endpoint (bool, optional) – If True, stop is the last sample. Otherwise, it is not included. Default is True.

  • dtype (Union[None, float64]) – allowed for compatibility with numpy, but ignored. Outputs are always float

  • axis (int, optional) – The axis in the result to store the samples. Relevant only if start or stop are array-like. By default (0), the samples will be along a new axis inserted at the beginning. Use -1 to get an axis at the end.

Returns:

There are num equally spaced (logarithmically) samples in the closed interval base**``[start, stop]`` or the half-open interval base**``[start, stop)`` (depending on whether endpoint is True or False).

Return type:

pdarray

Raises:
  • TypeError – Raised if start or stop is not a float or a pdarray, or if num is not an int, or if endpoint is not a bool, or if dtype is anything other than None or float64, or axis is not an integer.

  • ValueError – Raised if axis is not a valid axis for the given data, or if base < 0.

See also

linspace

Notes

If start is greater than stop, the pdarray values are generated in descending order.

Examples

>>> import arkouda as ak
>>> ak.logspace(2,3,3,4)
array([16.00000000000000000 32.00000000000000000 64.00000000000000000])
>>> ak.logspace(2,3,3,4,endpoint=False)
array([16.00000000000000000 25.398416831491197 40.317473596635935])
>>> ak.logspace(0,1,3,4)
array([1.00000000000000000 2.00000000000000000 4.00000000000000000])
>>> ak.logspace(1,0,3,4)
array([4.00000000000000000 2.00000000000000000 1.00000000000000000])
>>> ak.logspace(0,1,3,endpoint=False)
array([1.00000000000000000 2.1544346900318838 4.6415888336127784])
>>> ak.logspace(0,ak.array([2,3]),3,base=2)
array([array([1.00000000000000000 1.00000000000000000])
    array([2.00000000000000000 2.8284271247461903])
    array([4.00000000000000000 8.00000000000000000])])
>>> ak.logspace(ak.array([0,1]),3,3,base=3)
array([array([1.00000000000000000 3.00000000000000000])
    array([5.196152422706632 9.00000000000000000])
    array([27.00000000000000000 27.00000000000000000])])
>>> ak.logspace(ak.array([0,1]),ak.array([2,3]),3,base=4)
array([array([1.00000000000000000 4.00000000000000000])
    array([4.00000000000000000 16.00000000000000000])
    array([16.00000000000000000 64.00000000000000000])])
class arkouda.numpy.longdouble

Bases: numpy.floating

Extended-precision floating-point number type, compatible with C

long double but not necessarily with IEEE 754 quadruple-precision.

Character code:

'g'

Alias on this platform (Linux x86_64):

numpy.float128: 128-bit extended-precision floating-point number type.

as_integer_ratio(/)

longdouble.as_integer_ratio() -> (int, int)

Return a pair of integers, whose ratio is exactly equal to the original floating point number, and with a positive denominator. Raise OverflowError on infinities and a ValueError on NaNs.

>>> np.longdouble(10.0).as_integer_ratio()
(10, 1)
>>> np.longdouble(0.0).as_integer_ratio()
(0, 1)
>>> np.longdouble(-.25).as_integer_ratio()
(-1, 4)
is_integer(/)

longdouble.is_integer() -> bool

Return True if the floating point number is finite with integral value, and False otherwise.

Added in version 1.22.

>>> np.longdouble(-2.0).is_integer()
True
>>> np.longdouble(3.2).is_integer()
False
class arkouda.numpy.longlong

Bases: numpy.signedinteger

Signed integer type, compatible with C long long.

Character code:

'q'

bit_count(/)
arkouda.numpy.lookup(keys, values, arguments, fillvalue=-1)[source]

Apply the function defined by the mapping keys –> values to arguments.

Parameters:
  • keys ((sequence of) array-like) – The domain of the function. Entries must be unique (if a sequence of arrays is given, each row is treated as a tuple-valued entry).

  • values (pdarray) – The range of the function. Must be same length as keys.

  • arguments ((sequence of) array-like) – The arguments on which to evaluate the function. Must have same dtype (or tuple of dtypes, for a sequence) as keys.

  • fillvalue (scalar) – The default value to return for arguments not in keys.

Returns:

evaluated – The result of evaluating the function over arguments.

Return type:

pdarray

Notes

While the values cannot be Strings (or other complex objects), the same result can be achieved by passing an arange as the values, then using the return as indices into the desired object.

Examples

>>> import arkouda as ak

Lookup numbers by two-word name >>> keys1 = ak.array([‘twenty’ for _ in range(5)]) >>> keys2 = ak.array([‘one’, ‘two’, ‘three’, ‘four’, ‘five’]) >>> values = ak.array([21, 22, 23, 24, 25]) >>> args1 = ak.array([‘twenty’, ‘thirty’, ‘twenty’]) >>> args2 = ak.array([‘four’, ‘two’, ‘two’]) >>> ak.numpy.alignment.lookup([keys1, keys2], values, [args1, args2]) array([24 -1 22])

Other direction requires an intermediate index >>> revkeys = values >>> revindices = ak.arange(values.size) >>> revargs = ak.array([24, 21, 22]) >>> idx = ak.numpy.alignment.lookup(revkeys, revindices, revargs) >>> keys1[idx], keys2[idx] (array([‘twenty’, ‘twenty’, ‘twenty’]), array([‘four’, ‘one’, ‘two’]))

arkouda.numpy.matmul(pda_L: arkouda.numpy.pdarrayclass.pdarray, pda_R: arkouda.numpy.pdarrayclass.pdarray) arkouda.numpy.pdarrayclass.pdarray[source]

Compute the product of two matrices. If both are 1D, this returns a simple dot product. If both are 2D, it returns a conventional matrix multiplication. If only one is 1D, the result matches the “dot” function, so we use that. If neither is 1D and at least one is > 2D, then broadcasting is involved. If pda_L’s shape is [(leftshape),m,n] and pda_R’s shape is [(rightshape),n,k], then the result will have shape [(common shape),m,k] where common shape is a shape that both leftshape and rightshape can be broadcast to.

Parameters:
Returns:

the matrix product pda_L x pda_R

Return type:

pdarray

Examples

>>> import arkouda as ak
>>> a = ak.array([[1,2,3,4,5],[1,2,3,4,5]])
>>> b = ak.array([[1,1],[2,2],[3,3],[4,4],[5,5]])
>>> ak.matmul(a,b)
array([array([55 55]) array([55 55])])
>>> x = ak.array([[1,2,3],[1.1,2.1,3.1]])
>>> y = ak.array([[1,1,1],[0,2,2],[0,0,3]])
>>> ak.matmul(x,y)
array([array([1.00000000... 5.00000000... 14.0000000...])
array([1.10000000... 5.30000000... 14.6000000...])])
Raises:

ValueError – Raised if shapes are incompatible with matrix multiplication.

arkouda.numpy.maximum(x1: arkouda.numpy.pdarrayclass.pdarray | arkouda.numpy.dtypes.numeric_scalars, x2: arkouda.numpy.pdarrayclass.pdarray | arkouda.numpy.dtypes.numeric_scalars) arkouda.numpy.pdarrayclass.pdarray[source]

Return the element-wise maximum of x1 and x2. Where either is a nan, return nan, else the greater of x1, x2. If x1 and x2 are not the same shape, they are first broadcast to a mutual shape, if possible.

Parameters:
Returns:

The element-wise maximum of x1 and x2. If both are scalars, it invokes numpy maximum, otherwise where either is a nan, the returned pdarray Where neither is a nan, it stores the maximum of x1 and x2.

Return type:

pdarray, numeric_scalar

Examples

>>> import arkouda as ak
>>> a = ak.array([1.0,2.0,ak.nan])
>>> b = ak.array([0.5,2.5,3.5])
>>> ak.maximum(a,b)
array([1.00000000000000000 2.5 nan])
>>> c = ak.arange(4,dtype=ak.float64).reshape(2,2)
>>> d = ak.array([-0.5,2.5])
>>> ak.maximum(c,d)
array([array([0.00000000000000000 2.5]) array([2.00000000000000000 3.00000000000000000])])
arkouda.numpy.maxk(pda: pdarray, k: arkouda.numpy.dtypes.int_scalars) pdarray[source]

Find the k maximum values of an array.

Returns the largest k values of an array, sorted

Parameters:
  • pda (pdarray) – Input array.

  • k (int_scalars) – The desired count of maximum values to be returned by the output.

Returns:

The maximum k values from pda, sorted

Return type:

pdarray

Raises:
  • TypeError – Raised if pda is not a pdarray or k is not an integer

  • ValueError – Raised if the pda is empty, or pda.ndim > 1, or k < 1

Notes

This call is equivalent in value to a[ak.argsort(a)[k:]]

and generally outperforms this operation.

This reduction will see a significant drop in performance as k grows beyond a certain value. This value is system dependent, but generally about a k of 5 million is where performance degredation has been observed.

Examples

>>> import arkouda as ak
>>> A = ak.array([10,5,1,3,7,2,9,0])
>>> ak.maxk(A, 3)
array([7 9 10])
>>> ak.maxk(A, 4)
array([5 7 9 10])
arkouda.numpy.may_share_memory(a, b)[source]

Conservative version akin to numpy.may_share_memory.

For now it just defers to shares_memory.

arkouda.numpy.median(pda: arkouda.numpy.pdarrayclass.pdarray) numpy.float64[source]

Compute the median of a given array. 1d case only, for now.

Parameters:

pda (pdarray) – The input data, in pdarray form, numeric type or boolean

Returns:

The median of the entire pdarray
The array is sorted, and then if the number of elements is odd, the return value is the middle element. If even, then the mean of the two middle elements.

Return type:

np.float64

Examples

>>> import arkouda as ak
>>> pda = ak.array([0,4,7,8,1,3,5,2,-1])
>>> ak.median(pda)
np.float64(3.0)
>>> pda = ak.array([0,1,3,3,1,2,3,4,2,3])
>>> ak.median(pda)
np.float64(2.5)
arkouda.numpy.minimum(x1: arkouda.numpy.pdarrayclass.pdarray | arkouda.numpy.dtypes.numeric_scalars, x2: arkouda.numpy.pdarrayclass.pdarray | arkouda.numpy.dtypes.numeric_scalars) arkouda.numpy.pdarrayclass.pdarray[source]

Return the element-wise minimum of x1 and x2. Where either is a nan, return nan, else the lesser of x1, x2. If x1 and x2 are not the same shape, they are first broadcast to a mutual shape, if possible.

Parameters:
Returns:

The element-wise minimum of x1 and x2. If both are scalars, it invokes numpy minimum, otherwise where either is a nan, the returned pdarray Where neither is a nan, it stores the minimum of x1 and x2.

Return type:

pdarray, numeric_scalar

Examples

>>> import arkouda as ak
>>> a = ak.array([1.0,2.0,ak.nan])
>>> b = ak.array([0.5,2.5,3.5])
>>> ak.minimum(a,b)
array([0.5 2.00000000000000000 nan])
>>> c = ak.arange(4,dtype=ak.float64).reshape(2,2)
>>> d = ak.array([-0.5,2.5])
>>> ak.minimum(c,d)
array([array([-0.5 1.00000000000000000]) array([-0.5 2.5])])
arkouda.numpy.mink(pda: pdarray, k: arkouda.numpy.dtypes.int_scalars) pdarray[source]

Find the k minimum values of an array.

Returns the smallest k values of an array, sorted

Parameters:
  • pda (pdarray) – Input array.

  • k (int_scalars) – The desired count of minimum values to be returned by the output.

Returns:

The minimum k values from pda, sorted

Return type:

pdarray

Raises:
  • TypeError – Raised if pda is not a pdarray

  • ValueError – Raised if the pda is empty, or pda.ndim > 1, or k < 1

Notes

This call is equivalent in value to a[ak.argsort(a)[:k]] and generally outperforms this operation.

This reduction will see a significant drop in performance as k grows beyond a certain value. This value is system dependent, but generally about a k of 5 million is where performance degredation has been observed.

Examples

>>> import arkouda as ak
>>> A = ak.array([10,5,1,3,7,2,9,0])
>>> ak.mink(A, 3)
array([0 1 2])
>>> ak.mink(A, 4)
array([0 1 2 3])
arkouda.numpy.mod(dividend, divisor) pdarray[source]

Returns the element-wise remainder of division.

Computes the remainder complementary to the floor_divide function. It is equivalent to np.mod, the remainder has the same sign as the divisor.

Parameters:
  • dividend – pdarray : The numeric scalar or pdarray being acted on by the bases for the modular division.

  • divisor – pdarray : The numeric scalar or pdarray that will be the bases for the modular division.

Returns:

an array that contains the element-wise remainder of division.

Return type:

pdarray

Examples

>>> import arkouda as ak
>>> a = ak.array([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20])
>>> b = ak.array([2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,8,8])
>>> ak.mod(a,b)
array([1 0 1 1 2 0 3 0 1 0 1 2 1 2 3 2 3 4 3 4])
Raises:

ValueError – raised if shapes of dividend and divisor are incompatible

arkouda.numpy.nan: float
arkouda.numpy.newaxis: None
arkouda.numpy.nextafter(x1: arkouda.numpy.pdarrayclass.pdarray | arkouda.numpy.dtypes.numeric_scalars | arkouda.numpy.dtypes.bigint, x2: arkouda.numpy.pdarrayclass.pdarray | arkouda.numpy.dtypes.numeric_scalars | arkouda.numpy.dtypes.bigint) arkouda.numpy.pdarrayclass.pdarray | float[source]

Return the next floating-point value after x1 towards x2, element-wise. Accuracy only guaranteed for 64 bit values.

Parameters:
  • x1 (pdarray, numeric_scalars, or bigint) – Values to find the next representable value of.

  • x2 (pdarray, numeric_scalars, or bigint) – The direction where to look for the next representable value of x1. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

Returns:

The next representable values of x1 in the direction of x2. This is a scalar if both x1 and x2 are scalars.

Return type:

pdarray or float

Examples

>>> import arkouda as ak
>>> eps = np.finfo(np.float64).eps
>>> ak.nextafter(1, 2) == 1 + eps
 np.True_
>>> a = ak.array([1, 2])
>>> b = ak.array([2, 1])
>>> ak.nextafter(a, b) == ak.array([eps + 1, 2 - eps])
array([True True])
class arkouda.numpy.number

Bases: numpy.generic

Abstract base class of all numeric scalar types.

class arkouda.numpy.numeric_and_bool_scalars

Bases: _NotIterable

Mixin to prevent iteration, without being compatible with Iterable.

That is, we could do:

def __iter__(self): raise TypeError()

But this would make users of this mixin duck type-compatible with collections.abc.Iterable - isinstance(foo, Iterable) would be True.

Luckily, we can instead prevent iteration by setting __iter__ to None, which is treated specially.

copy_with(params)
class arkouda.numpy.numeric_scalars

Bases: _NotIterable

Mixin to prevent iteration, without being compatible with Iterable.

That is, we could do:

def __iter__(self): raise TypeError()

But this would make users of this mixin duck type-compatible with collections.abc.Iterable - isinstance(foo, Iterable) would be True.

Luckily, we can instead prevent iteration by setting __iter__ to None, which is treated specially.

copy_with(params)
class arkouda.numpy.numpy_scalars

Bases: _NotIterable

Mixin to prevent iteration, without being compatible with Iterable.

That is, we could do:

def __iter__(self): raise TypeError()

But this would make users of this mixin duck type-compatible with collections.abc.Iterable - isinstance(foo, Iterable) would be True.

Luckily, we can instead prevent iteration by setting __iter__ to None, which is treated specially.

copy_with(params)
arkouda.numpy.ones(size: arkouda.numpy.dtypes.int_scalars | Tuple[arkouda.numpy.dtypes.int_scalars, Ellipsis] | str, dtype: numpy.dtype | type | str | arkouda.numpy.dtypes.bigint = float64, max_bits: int | None = None) arkouda.numpy.pdarrayclass.pdarray[source]

Create a pdarray filled with ones.

Parameters:
  • size (int_scalars or tuple of int_scalars) – Size or shape of the array

  • dtype (Union[float64, int64, bool]) – Resulting array type, default ak.float64

  • max_bits (int) – Specifies the maximum number of bits; only used for bigint pdarrays Included for consistency, as ones are all zeros ending on a one, regardless of max_bits

Returns:

Ones of the requested size or shape and dtype

Return type:

pdarray

Raises:
  • TypeError – Raised if the supplied dtype is not supported

  • RuntimeError – Raised if the size parameter is neither an int nor a str that is parseable to an int.

  • ValueError – Raised if the rank of the given shape is not in get_array_ranks() or is empty

See also

zeros, ones_like

Examples

>>> import arkouda as ak
>>> ak.ones(5, dtype=ak.int64)
array([1 1 1 1 1])
>>> ak.ones(5, dtype=ak.float64)
array([1.00000000000000000 1.00000000000000000 1.00000000000000000
       1.00000000000000000 1.00000000000000000])
>>> ak.ones(5, dtype=ak.bool_)
array([True True True True True])

Notes

Logic for generating the pdarray is delegated to the ak.full method.

arkouda.numpy.ones_like(pda: arkouda.numpy.pdarrayclass.pdarray) arkouda.numpy.pdarrayclass.pdarray[source]

Create a one-filled pdarray of the same size and dtype as an existing pdarray.

Parameters:

pda (pdarray) – Array to use for shape and dtype

Returns:

Equivalent to ak.ones(pda.size, pda.dtype)

Return type:

pdarray

Raises:

TypeError – Raised if the pda parameter is not a pdarray.

See also

ones, zeros_like

Notes

Logic for generating the pdarray is delegated to the ak.ones method. Accordingly, the supported dtypes match are defined by the ak.ones method.

Examples

>>> import arkouda as ak
>>> ak.ones_like(ak.zeros(5,dtype=ak.int64))
array([1 1 1 1 1])
>>> ak.ones_like(ak.zeros(5,dtype=ak.float64))
array([1.00000000000000000 1.00000000000000000 1.00000000000000000
       1.00000000000000000 1.00000000000000000])
>>> ak.ones_like(ak.zeros(5,dtype=ak.bool_))
array([True True True True True])
arkouda.numpy.parity(pda: pdarray) pdarray[source]

Find the bit parity (XOR of all bits) for each integer in an array.

Parameters:

pda (pdarray, int64, uint64, bigint) – Input array (must be integral).

Returns:

The parity of each element: 0 if even number of bits set, 1 if odd.

Return type:

pdarray

Raises:

TypeError – If input array is not int64, uint64, or bigint

Examples

>>> import arkouda as ak
>>> A = ak.arange(10)
>>> ak.parity(A)
array([0 1 1 0 1 0 0 1 1 0])
class arkouda.numpy.pdarray(name: str, mydtype: numpy.dtype, size: arkouda.numpy.dtypes.int_scalars, ndim: arkouda.numpy.dtypes.int_scalars, shape: Tuple[int, Ellipsis], itemsize: arkouda.numpy.dtypes.int_scalars, max_bits: int | None = None)[source]

The basic arkouda array class. This class contains only the attributes of the array; the data resides on the arkouda server. When a server operation results in a new array, arkouda will create a pdarray instance that points to the array data on the server. As such, the user should not initialize pdarray instances directly.

name

The server-side identifier for the array

Type:

str

dtype

The element dtype of the array

Type:

type

size

The number of elements in the array

Type:

int_scalars

ndim

The rank of the array

Type:

int_scalars

shape

A tuple containing the sizes of each dimension of the array

Type:

Tuple[int, …]

itemsize

The size in bytes of each element

Type:

int_scalars

BinOps
OpEqOps
all(axis: int | Tuple[int, Ellipsis] | None = None, keepdims: bool = False) arkouda.numpy.dtypes.bool_scalars | pdarray[source]

Return True iff all elements of the array along the given axis evaluate to True.

Parameters:
  • axis (int, Tuple[int, ...], optional, default = None) – The axis or axes along which to do the operation If None, the computation is done across the entire array.

  • keepdims (bool, optional, default = False) – Whether to keep the singleton dimension(s) along axis in the result.

Returns:

boolean if axis is omitted, pdarray if axis is supplied

Return type:

boolean or pdarray

Examples

>>> import arkouda as ak
>>> ak.all(ak.array([True,False,False]))
np.False_
>>> ak.all(ak.array([[True,True,False],[False,True,True]]),axis=0)
array([False True False])
>>> ak.all(ak.array([[True,True,True],[False,False,False]]),axis=0,keepdims=True)
array([array([False False False])])
>>> ak.all(ak.array([[True,True,True],[False,False,False]]),axis=1,keepdims=True)
array([array([True]) array([False])])
>>> ak.array([True,False,False]).all()
np.False_
Raises:
  • TypeError – Raised if pda is not a pdarray instance

  • RuntimeError – Raised if there’s a server-side error thrown

Notes

Works as a method of a pdarray (e.g. a.any()) or a standalone function (e.g. ak.all(a))

any(axis: int | Tuple[int, Ellipsis] | None = None, keepdims: bool = False) arkouda.numpy.dtypes.bool_scalars | pdarray[source]

Return True iff any element of the array along the given axis evaluates to True.

Parameters:
  • axis (int, Tuple[int, ...], optional, default = None) – The axis or axes along which to do the operation If None, the computation is done across the entire array.

  • keepdims (bool, optional, default = False) – Whether to keep the singleton dimension(s) along axis in the result.

Returns:

boolean if axis is omitted, else pdarray if axis is supplied

Return type:

boolean or pdarray

Examples

>>> import arkouda as ak
>>> ak.any(ak.array([True,False,False]))
np.True_
>>> ak.any(ak.array([[True,True,False],[False,True,True]]),axis=0)
array([True True True])
>>> ak.any(ak.array([[True,True,True],[False,False,False]]),axis=0,keepdims=True)
array([array([True True True])])
>>> ak.any(ak.array([[True,True,True],[False,False,False]]),axis=1,keepdims=True)
array([array([True]) array([False])])
>>> ak.array([True,False,False]).any()
np.True_
Raises:
  • TypeError – Raised if pda is not a pdarray instance

  • RuntimeError – Raised if there’s a server-side error thrown

Notes

Works as a method of a pdarray (e.g. a.any()) or a standalone function (e.g. ak.any(a))

argmax(axis: int | None | None = None, keepdims: bool = False) numpy.int64 | numpy.uint64 | pdarray[source]

Return index of the first occurrence of the maximum along the given axis.

Parameters:
  • axis (int, Tuple[int, ...], optional, default = None) – The axis or axes along which to do the operation If None, the computation is done across the entire array.

  • keepdims (bool, optional, default = False) – Whether to keep the singleton dimension(s) along axis in the result.

Returns:

int64 or uint64 if axis is omitted, in which case operation is done over entire array pdarray if axis is supplied, in which case the operation is done along that axis

Return type:

int64, uint64 or pdarray

Raises:
  • TypeError – Raised if pda is not a pdarray instance

  • RuntimeError – Raised if there’s a server-side error thrown

Examples

>>> import arkouda as ak
>>> ak.argmax(ak.array([1,2,3,4,5]))
np.int64(4)
>>> ak.argmax(ak.array([5.5,4.5,3.5,2.5,1.5]))
np.int64(0)
>>> ak.array([[1,2,3],[5,4,3]]).argmax(axis=1)
array([2 0])

Notes

Works as a method of a pdarray (e.g. a.argmax()) or a standalone function (e.g. ak.argmax(a))

argmaxk(k: arkouda.numpy.dtypes.int_scalars) pdarray[source]

Finds the indices corresponding to the k maximum values of an array.

See arkouda.argmaxk for details.

argmin(axis: int | None | None = None, keepdims: bool = False) numpy.int64 | numpy.uint64 | pdarray[source]

Return index of the first occurrence of the minimum along the given axis.

Parameters:
  • axis (int, Tuple[int, ...], optional, default = None) – The axis or axes along which to do the operation If None, the computation is done across the entire array.

  • keepdims (bool, optional, default = False) – Whether to keep the singleton dimension(s) along axis in the result.

Returns:

int64 or uint64 if axis is omitted, in which case operation is done over entire array pdarray if axis is supplied, in which case the operation is done along that axis

Return type:

int64, uint64 or pdarray

Raises:
  • TypeError – Raised if pda is not a pdarray instance

  • RuntimeError – Raised if there’s a server-side error thrown

Examples

>>> import arkouda as ak
>>> ak.argmin(ak.array([1,2,3,4,5]))
np.int64(0)
>>> ak.argmin(ak.array([5.5,4.5,3.5,2.5,1.5]))
np.int64(4)
>>> ak.array([[1,2,3],[5,4,3]]).argmin(axis=1)
array([0 2])

Notes

Works as a method of a pdarray (e.g. a.argmin()) or a standalone function (e.g. ak.argmin(a))

argmink(k: arkouda.numpy.dtypes.int_scalars) pdarray[source]

Finds the indices corresponding to the k minimum values of an array.

See arkouda.argmink for details.

argsort(algorithm: arkouda.numpy.sorting.SortingAlgorithm = SortingAlgorithm.RadixSortLSD, axis: arkouda.numpy.dtypes.int_scalars = 0, ascending: bool = True) pdarray[source]

Return the permutation that sorts the pdarray.

Parameters:
  • algorithm (SortingAlgorithm, default SortingAlgorithm.RadixSortLSD) – The algorithm to use for sorting.

  • axis (int_scalars, default 0) – The axis to sort along. Must be between -1 and the array rank.

  • ascending (bool, default True) – Whether to sort in ascending order. If False, returns a reversed permutation. Note: ascending=False is only supported for 1D arrays.

Returns:

The indices that would sort the array.

Return type:

pdarray

Examples

>>> import arkouda as ak
>>> a = ak.array([42, 7, 19])
>>> a.argsort()
array([1 2 0])
>>> a[a.argsort()]
array([7 19 42])
>>> a.argsort(ascending=False)
array([0 2 1])
astype(dtype) pdarray[source]

Cast values of pdarray to provided dtype.

Parameters:

dtype (np.dtype or str) – Dtype to cast to

Examples

>>> import arkouda as ak
>>> ak.array([1,2,3]).astype(ak.float64)
array([1.00000000000000000 2.00000000000000000 3.00000000000000000])
>>> ak.array([1.5,2.5]).astype(ak.int64)
array([1 2])
>>> ak.array([True,False]).astype(ak.int64)
array([1 0])
Returns:

An arkouda pdarray with values converted to the specified data type

Return type:

pdarray

Notes

This is essentially shorthand for ak.cast(x, ‘<dtype>’) where x is a pdarray.

bigint_to_uint_arrays() List[pdarray][source]

Create a list of uint pdarrays from a bigint pdarray. The first item in return will be the highest 64 bits of the bigint pdarray and the last item will be the lowest 64 bits.

Returns:

A list of uint pdarrays where: The first item in return will be the highest 64 bits of the bigint pdarray and the last item will be the lowest 64 bits.

Return type:

List[pdarrays]

Raises:

RuntimeError – Raised if there is a server-side error thrown

Examples

>>> import arkouda as ak
>>> a = ak.arange(2**64, 2**64 + 5)
>>> a
array([18446744073709551616 18446744073709551617 18446744073709551618
18446744073709551619 18446744073709551620])
>>> a.bigint_to_uint_arrays()
[array([1 1 1 1 1]), array([0 1 2 3 4])]
clz() pdarray[source]

Count the number of leading zeros in each element.

See ak.clz.

copy() pdarray[source]

Return an array copy of the given object.

Returns:

A deep copy of the pdarray.

Return type:

pdarray

corr(y: pdarray) numpy.float64[source]

Compute the correlation between self and y using pearson correlation coefficient.

See arkouda.corr for details.

cov(y: pdarray) numpy.float64[source]

Compute the covariance between self and y.

ctz() pdarray[source]

Count the number of trailing zeros in each element.

See ak.ctz.

dtype: numpy.dtype
equals(other) arkouda.numpy.dtypes.bool_scalars[source]

Whether pdarrays are the same size and all entries are equal.

Parameters:

other (object) – object to compare.

Returns:

True if the pdarrays are the same, o.w. False.

Return type:

bool_scalars

Examples

>>> import arkouda as ak
>>> a = ak.array([1, 2, 3])
>>> a_cpy = ak.array([1, 2, 3])
>>> a.equals(a_cpy)
np.True_
>>> a2 = ak.array([1, 2, 5])
>>> a.equals(a2)
np.False_
fill(value: arkouda.numpy.dtypes.numeric_scalars | arkouda.numpy.dtypes.bool_scalars) None[source]

Fill the array (in place) with a constant value.

Parameters:

value (numeric_scalars)

Raises:

TypeError – Raised if value is not an int, int64, float, or float64

flatten()[source]

Return a copy of the array collapsed into one dimension.

Return type:

A copy of the input array, flattened to one dimension.

Examples

>>> import arkouda as ak
>>> a = ak.array([[3,2,1],[2,3,1]])
>>> a.flatten()
array([3 2 1 2 3 1])
format_other(other) str[source]

Attempt to cast scalar other to the element dtype of this pdarray, and print the resulting value to a string (e.g. for sending to a server command). The user should not call this function directly.

Parameters:

other (object) – The scalar to be cast to the pdarray.dtype

Return type:

string representation of np.dtype corresponding to the other parameter

Raises:

TypeError – Raised if the other parameter cannot be converted to Numpy dtype

property inferred_type: str | None

Return a string of the type inferred from the values.

info() str[source]

Return a JSON formatted string containing information about all components of self.

Returns:

JSON string containing information about all components of self

Return type:

str

is_registered() numpy.bool_[source]

Return True iff the object is contained in the registry.

Returns:

Indicates if the object is contained in the registry

Return type:

bool

Raises:

RuntimeError – Raised if there’s a server-side error thrown

Note

This will return True if the object is registered itself or as a component of another object

is_sorted(axis: int | Tuple[int, Ellipsis] | None = None, keepdims: bool = False) arkouda.numpy.dtypes.bool_scalars | pdarray[source]

Return True iff the array (or given axis of the array) is monotonically non-decreasing.

Parameters:
  • axis (int, Tuple[int, ...], optional, default = None) – The axis or axes along which to do the operation If None, the computation is done across the entire array.

  • keepdims (bool, optional, default = False) – Whether to keep the singleton dimension(s) along axis in the result.

Returns:

boolean if axis is omitted, else pdarray if axis is supplied

Return type:

boolean or pdarray

Raises:
  • TypeError – Raised if pda is not a pdarray instance

  • RuntimeError – Raised if there’s a server-side error thrown

Examples

>>> import arkouda as ak
>>> ak.is_sorted(ak.array([1,2,3,4,5]))
np.True_
>>> ak.is_sorted(ak.array([5,4,3,2,1]))
np.False_
>>> ak.array([[1,2,3],[5,4,3]]).is_sorted(axis=1)
array([True False])

Notes

Works as a method of a pdarray (e.g. a.is_sorted()) or a standalone function (e.g. ak.is_sorted(a))

itemsize: arkouda.numpy.dtypes.int_scalars
logical_not() pdarray[source]

Compute the truth value of NOT self element-wise.

This method is equivalent to arkouda.logical_not(self)(). It returns a boolean pdarray where each element is the logical negation of the corresponding element in self.

Returns:

A boolean pdarray with the same shape as self containing the result of the NOT operation.

Return type:

pdarray

Examples

>>> import arkouda as ak
>>> a = ak.array([True, False, True])
>>> a.logical_not()
array([False  True False])
>>> ak.logical_not(a)
array([False  True False])

Notes

Works as a method of a pdarray (e.g. a.logical_not()) or as a standalone function (e.g. ak.logical_not(a)). For boolean arrays, this is equivalent to applying the unary ~ operator. For numeric arrays, zero is treated as False and non-zero as True.

max(axis: int | Tuple[int, Ellipsis] | None = None, keepdims: bool = False) arkouda.numpy.dtypes.numeric_scalars | pdarray[source]

Return max of array elements along the given axis.

Parameters:
  • axis (int, Tuple[int, ...], optional, default = None) – The axis or axes along which to do the operation If None, the computation is done across the entire array.

  • keepdims (bool, optional, default = False) – Whether to keep the singleton dimension(s) along axis in the result.

Returns:

numeric_scalar if axis is omitted, in which case operation is done over entire array pdarray if axis is supplied, in which case the operation is done along that axis

Return type:

numeric_scalar or pdarray

Raises:
  • TypeError – Raised if pda is not a pdarray instance

  • RuntimeError – Raised if there’s a server-side error thrown

Examples

>>> import arkouda as ak
>>> ak.max(ak.array([1,2,3,4,5]))
np.int64(5)
>>> ak.max(ak.array([5.5,4.5,3.5,2.5,1.5]))
np.float64(5.5)
>>> ak.array([[1,2,3],[5,4,3]]).max(axis=1)
array([3 5])

Notes

Works as a method of a pdarray (e.g. a.max()) or a standalone function (e.g. ak.max(a))

property max_bits
maxk(k: arkouda.numpy.dtypes.int_scalars) pdarray[source]

Compute the maximum “k” values.

See arkouda.maxk for details.

mean(axis: int | Tuple[int, Ellipsis] | None = None, keepdims: bool = False) arkouda.numpy.dtypes.numeric_scalars | pdarray[source]

Return the mean of the array.

Parameters:
  • axis (int, Tuple[int, ...], optional, default = None) – The axis or axes along which to do the operation If None, the computation is done across the entire array.

  • keepdims (bool, optional, default = False) – Whether to keep the singleton dimension(s) along axis in the result.

Returns:

The mean calculated from the pda sum and size, along the axis/axes if those are given.

Return type:

Union[np.float64, pdarray]

Examples

>>> import arkouda as ak
>>> a = ak.arange(10)
>>> ak.mean(a)
np.float64(4.5)
>>> a.mean()
np.float64(4.5)
>>> a = ak.arange(10).reshape(2,5)
>>> a.mean(axis=0)
array([2.5 3.5 4.5 5.5 6.5])
>>> ak.mean(a,axis=0)
array([2.5 3.5 4.5 5.5 6.5])
>>> a.mean(axis=1)
array([2.00000000000000000 7.00000000000000000])
>>> ak.mean(a,axis=1)
array([2.00000000000000000 7.00000000000000000])
Raises:

Raised if pda is not a pdarray instance

RuntimeError

Raised if there’s a server-side error thrown

min(axis: int | Tuple[int, Ellipsis] | None = None, keepdims: bool = False) arkouda.numpy.dtypes.numeric_scalars | pdarray[source]

Return min of array elements along the given axis.

Parameters:
  • axis (int, Tuple[int, ...], optional, default = None) – The axis or axes along which to do the operation If None, the computation is done across the entire array.

  • keepdims (bool, optional, default = False) – Whether to keep the singleton dimension(s) along axis in the result.

Returns:

numeric_scalar if axis is omitted, in which case operation is done over entire array pdarray if axis is supplied, in which case the operation is done along that axis

Return type:

numeric_scalar or pdarray

Raises:
  • TypeError – Raised if pda is not a pdarray instance

  • RuntimeError – Raised if there’s a server-side error thrown

Examples

>>> import arkouda as ak
>>> ak.min(ak.array([1,2,3,4,5]))
np.int64(1)
>>> ak.min(ak.array([5.5,4.5,3.5,2.5,1.5]))
np.float64(1.5)
>>> ak.array([[1,2,3],[5,4,3]]).min(axis=1)
array([1 3])

Notes

Works as a method of a pdarray (e.g. a.min()) or a standalone function (e.g. ak.min(a))

mink(k: arkouda.numpy.dtypes.int_scalars) pdarray[source]

Compute the minimum “k” values.

See arkouda.mink for details.

name: str
property nbytes

The size of the pdarray in bytes.

Returns:

The size of the pdarray in bytes.

Return type:

int

ndim: arkouda.numpy.dtypes.int_scalars
objType = 'pdarray'
opeq(other, op)[source]
parity() pdarray[source]

Find the parity (XOR of all bits) in each element.

See ak.parity.

popcount() pdarray[source]

Find the population (number of bits set) in each element.

See ak.popcount.

pretty_print_info() None[source]

Print information about all components of self in a human-readable format.

prod(axis: int | Tuple[int, Ellipsis] | None = None, keepdims: bool = False) arkouda.numpy.dtypes.numeric_scalars | pdarray[source]

Return prod of array elements along the given axis.

Parameters:
  • axis (int, Tuple[int, ...], optional, defalt = None) – The axis or axes along which to do the operation If None, the computation is done across the entire array.

  • keepdims (bool, optional, default = False) – Whether to keep the singleton dimension(s) along axis in the result.

Returns:

numeric_scalars if axis is omitted, in which case operation is done over entire array pdarray if axis is supplied, in which case the operation is done along that axis

Return type:

numeric_scalars or pdarray

Raises:
  • TypeError – Raised if pda is not a pdarray instance

  • RuntimeError – Raised if there’s a server-side error thrown

Examples

>>> import arkouda as ak
>>> ak.prod(ak.array([1,2,3,4,5]))
np.int64(120)
>>> ak.prod(ak.array([5.5,4.5,3.5,2.5,1.5]))
np.float64(324.84375)
>>> ak.array([[1,2,3],[5,4,3]]).prod(axis=1)
array([6 60])

Notes

Works as a method of a pdarray (e.g. a.prod()) or a standalone function (e.g. ak.prod(a))

register(user_defined_name: str) pdarray[source]

Register this pdarray with a user defined name in the arkouda server so it can be attached to later using pdarray.attach().

This is an in-place operation, registering a pdarray more than once will update the name in the registry and remove the previously registered name. A name can only be registered to one pdarray at a time.

Parameters:

user_defined_name (str) – user defined name array is to be registered under

Returns:

The same pdarray which is now registered with the arkouda server and has an updated name. This is an in-place modification, the original is returned to support a fluid programming style. Please note you cannot register two different pdarrays with the same name.

Return type:

pdarray

Raises:
  • TypeError – Raised if user_defined_name is not a str

  • RegistrationError – If the server was unable to register the pdarray with the user_defined_name If the user is attempting to register more than one pdarray with the same name, the former should be unregistered first to free up the registration name.

See also

attach, unregister, is_registered, list_registry, unregister_pdarray_by_name

Notes

Registered names/pdarrays in the server are immune to deletion until they are unregistered.

Examples

>>> import arkouda as ak
>>> a = ak.zeros(3)
>>> a.register("my_zeros")
array([0.00000000000000000 0.00000000000000000 0.00000000000000000])

potentially disconnect from server and reconnect to server >>> b = ak.attach(“my_zeros”) >>> b.unregister()

registered_name: str | None = None
reshape(*shape)[source]

Gives a new shape to an array without changing its data.

Parameters:

shape (int, tuple of ints, or pdarray) – The new shape should be compatible with the original shape.

Returns:

a pdarray with the same data, reshaped to the new shape

Return type:

pdarray

Examples

>>> import arkouda as ak
>>> a = ak.array([[3,2,1],[2,3,1]])
>>> a.reshape((3,2))
array([array([3 2]) array([1 2]) array([3 1])])
>>> a.reshape(3,2)
array([array([3 2]) array([1 2]) array([3 1])])
>>> a.reshape((6,1))
array([array([3]) array([2]) array([1]) array([2]) array([3]) array([1])])

Notes

only available as a method, not as a standalone function, i.e., a.reshape(compatibleShape) is valid, but ak.reshape(a,compatibleShape) is not.

rotl(other) pdarray[source]

Rotate bits left by <other>.

rotr(other) pdarray[source]

Rotate bits right by <other>.

property shape

Return the shape of an array.

Returns:

The elements of the shape tuple give the lengths of the corresponding array dimensions.

Return type:

tuple of int

size: arkouda.numpy.dtypes.int_scalars
slice_bits(low, high) pdarray[source]

Return a pdarray containing only bits from low to high of self.

This is zero indexed and inclusive on both ends, so slicing the bottom 64 bits is pda.slice_bits(0, 63)

Parameters:
  • low (int) – The lowest bit included in the slice (inclusive) zero indexed, so the first bit is 0

  • high (int) – The highest bit included in the slice (inclusive)

Returns:

A new pdarray containing the bits of self from low to high

Return type:

pdarray

Raises:

RuntimeError – Raised if there is a server-side error thrown

Examples

>>> import arkouda as ak
>>> p = ak.array([2**65 + (2**64 - 1)])
>>> bin(p[0])
'0b101111111111111111111111111111111111111111111111111111111111111111'
>>> bin(p.slice_bits(64, 65)[0])
'0b10'
>>> a = ak.array([143,15])
>>> a.slice_bits(1,3)
array([7 7])
>>> a.slice_bits(4,9)
array([8 0])
>>> a.slice_bits(1,9)
array([71 7])
std(ddof: arkouda.numpy.dtypes.int_scalars = 0, axis: int | Tuple[int, Ellipsis] | None = None, keepdims: bool | None = False) numpy.float64 | pdarray[source]

Return the standard deviation of values in the array. The standard deviation is implemented as the square root of the variance.

Parameters:
  • ddof (int_scalars) – “Delta Degrees of Freedom” used in calculating std

  • axis (int, Tuple[int, ...], optional, default = None) – The axis or axes along which to do the operation If None, the computation is done across the entire array.

  • keepdims (bool, optional, default = False) – Whether to keep the singleton dimension(s) along axis in the result.

Returns:

The scalar standard deviation of the array, or the standard deviation

along the axis/axes if supplied

Return type:

Union[np.float64, pdarray]

Examples

>>> import arkouda as ak
>>> a = ak.arange(10)
>>> ak.std(a)
np.float64(2.8722813232690143)
>>> a.std()
np.float64(2.8722813232690143)
>>> a = ak.arange(10).reshape(2,5)
>>> a.std(axis=0)
array([2.5 2.5 2.5 2.5 2.5])
>>> ak.std(a,axis=0)
array([2.5 2.5 2.5 2.5 2.5])
>>> a.std(axis=1)
array([1.4142135623730951 1.4142135623730951])
>>> ak.std(a,axis=1)
array([1.4142135623730951 1.4142135623730951])
Raises:
  • TypeError – Raised if pda is not a pdarray instance or ddof is not an integer

  • ValueError – Raised if ddof is an integer < 0

  • RuntimeError – Raised if there’s a server-side error thrown

See also

mean, var

Notes

The standard deviation is the square root of the average of the squared deviations from the mean, i.e., std = sqrt(mean((x - x.mean())**2)).

The average squared deviation is normally calculated as x.sum() / N, where N = len(x). If, however, ddof is specified, the divisor N - ddof is used instead. In standard statistical practice, ddof=1 provides an unbiased estimator of the variance of the infinite population. ddof=0 provides a maximum likelihood estimate of the variance for normally distributed variables. The standard deviation computed in this function is the square root of the estimated variance, so even with ddof=1, it will not be an unbiased estimate of the standard deviation per se.

sum(axis: int | Tuple[int, Ellipsis] | None = None, keepdims: bool = False) arkouda.numpy.dtypes.numeric_scalars | pdarray[source]

Return sum of array elements along the given axis.

Parameters:
  • axis (int, Tuple[int, ...], optional, default = None) – The axis or axes along which to do the operation If None, the computation is done across the entire array.

  • keepdims (bool, optional, default = False) – Whether to keep the singleton dimension(s) along axis in the result.

Returns:

numeric_scalars if axis is omitted, in which case operation is done over entire array pdarray if axis is supplied, in which case the operation is done along that axis

Return type:

numeric_scalars or pdarray

Raises:
  • TypeError – Raised if pda is not a pdarray instance

  • RuntimeError – Raised if there’s a server-side error thrown

Examples

>>> import arkouda as ak
>>> ak.sum(ak.array([1,2,3,4,5]))
np.int64(15)
>>> ak.sum(ak.array([5.5,4.5,3.5,2.5,1.5]))
np.float64(17.5)
>>> ak.array([[1,2,3],[5,4,3]]).sum(axis=1)
array([6 12])

Notes

Works as a method of a pdarray (e.g. a.sum()) or a standalone function (e.g. ak.sum(a))

take(indices: arkouda.numpy.dtypes.numeric_scalars | pdarray, axis: int | None = None) pdarray[source]

Take elements from the array along an axis.

When axis is not None, this function does the same thing as “fancy” indexing (indexing arrays using arrays); however, it can be easier to use if you need elements along a given axis. A call such as np.take(arr, indices, axis=3) is equivalent to arr[:,:,:,indices,...].

Parameters:
  • indices (numeric_scalars or pdarray) – The indices of the values to extract. Also allow scalars for indices.

  • axis (int, optional) – The axis over which to select values. By default, the flattened input array is used.

Returns:

The returned array has the same type as a.

Return type:

pdarray

Examples

>>> import arkouda as ak
>>> a = ak.array([4, 3, 5, 7, 6, 8])
>>> indices = [0, 1, 4]
>>> a.take(indices)
array([4 3 6])
to_csv(prefix_path: str, dataset: str = 'array', col_delim: str = ',', overwrite: bool = False)[source]

Write pdarry to CSV file(s). File will contain a single column with the pdarray data. All CSV files written by Arkouda include a header denoting data types of the columns.

Parameters:
  • prefix_path (str) – filename prefix to be used for saving files. Files will have _LOCALE#### appended when they are written to disk.

  • dataset (str, defaults to "array") – column name to save the pdarray under.

  • col_delim (str, defaults to ",") – value to be used to separate columns within the file. Please be sure that the value used DOES NOT appear in your dataset.

  • overwrite (bool, defaults to False) – If True, existing files matching the provided path will be overwritten. if False and existing files are found, an error will be returned.

Returns:

response message

Return type:

str

Raises:
  • ValueError – Raised if all datasets are not present in all parquet files or if one or more of the specified files do not exist

  • RuntimeError – Raised if one or more of the specified files cannot be opened. if ‘allow_errors’ is true, this may be raised if no values are returned from the server.

  • TypeError – Raise if the server returns an unknown arkouda_type

Notes

  • CSV format is not currently supported by load/load_all operations

  • The column delimiter is expected to be the same for all column names and data

  • Be sure that column delimiters are not found within your data.

  • All CSV files must delimit rows using newline (”\n”) at this time.

to_cuda()[source]

Convert the array to a Numba DeviceND array, transferring array data from the arkouda server to Python via ndarray. If the array exceeds a builtin size limit, a RuntimeError is raised.

Returns:

A Numba ndarray with the same attributes and data as the pdarray; on GPU

Return type:

numba.DeviceNDArray

Raises:
  • ImportError – Raised if CUDA is not available

  • ModuleNotFoundError – Raised if Numba is either not installed or not enabled

  • RuntimeError – Raised if there is a server-side error thrown in the course of retrieving the pdarray.

Notes

The number of bytes in the array cannot exceed client.maxTransferBytes, otherwise a RuntimeError will be raised. This is to protect the user from overflowing the memory of the system on which the Python client is running, under the assumption that the server is running on a distributed system with much more memory than the client. The user may override this limit by setting client.maxTransferBytes to a larger value, but proceed with caution.

See also

array

Examples

>>> import arkouda as ak
>>> a = ak.arange(0, 5, 1)
>>> a.to_cuda()
array([0, 1, 2, 3, 4])
>>> type(a.to_cuda())
numpy.devicendarray
to_hdf(prefix_path: str, dataset: str = 'array', mode: Literal['truncate', 'append'] = 'truncate', file_type: Literal['single', 'distribute'] = 'distribute') str[source]

Save the pdarray to HDF5. The object can be saved to a collection of files or single file.

Parameters:
  • prefix_path (str) – Directory and filename prefix that all output files share

  • dataset (str) – Name of the dataset to create in files (must not already exist)

  • mode ({'truncate', 'append'}) – By default, truncate (overwrite) output files, if they exist. If ‘append’, attempt to create new dataset in existing files.

  • file_type ({"single", "distribute"}) – Default: “distribute” When set to single, dataset is written to a single file. When distribute, dataset is written on a file per locale. This is only supported by HDF5 files and will have no impact of Parquet Files.

Return type:

string message indicating result of save operation

Raises:

RuntimeError – Raised if a server-side error is thrown saving the pdarray

Notes

  • The prefix_path must be visible to the arkouda server and the user must

have write permission. - Output files have names of the form <prefix_path>_LOCALE<i>, where <i> ranges from 0 to numLocales for file_type=’distribute’. Otherwise, the file name will be prefix_path. - If any of the output files already exist and the mode is ‘truncate’, they will be overwritten. If the mode is ‘append’ and the number of output files is less than the number of locales or a dataset with the same name already exists, a RuntimeError will result. - Any file extension can be used.The file I/O does not rely on the extension to determine the file format.

Examples

>>> import arkouda as ak
>>> a = ak.arange(25)

Saving without an extension >>> a.to_hdf(‘path/prefix’, dataset=’array’) # doctest: +SKIP Saves the array to numLocales HDF5 files with the name cwd/path/name_prefix_LOCALE####

Saving with an extension (HDF5) >>> a.to_hdf(‘path/prefix.h5’, dataset=’array’) # doctest: +SKIP Saves the array to numLocales HDF5 files with the name cwd/path/name_prefix_LOCALE####.h5 where #### is replaced by each locale number

Saving to a single file >>> a.to_hdf(‘path/prefix.hdf5’, dataset=’array’, file_type=’single’) # doctest: +SKIP Saves the array in to single hdf5 file on the root node. cwd/path/name_prefix.hdf5

to_ndarray() numpy.ndarray[source]

Convert the array to a np.ndarray, transferring array data from the Arkouda server to client-side Python. Note: if the pdarray size exceeds client.maxTransferBytes, a RuntimeError is raised.

Returns:

A numpy ndarray with the same attributes and data as the pdarray

Return type:

np.ndarray

Raises:

RuntimeError – Raised if there is a server-side error thrown, if the pdarray size exceeds the built-in client.maxTransferBytes size limit, or if the bytes received does not match expected number of bytes

Notes

The number of bytes in the array cannot exceed client.maxTransferBytes, otherwise a RuntimeError will be raised. This is to protect the user from overflowing the memory of the system on which the Python client is running, under the assumption that the server is running on a distributed system with much more memory than the client. The user may override this limit by setting client.maxTransferBytes to a larger value, but proceed with caution.

See also

array, tolist

Examples

>>> import arkouda as ak
>>> a = ak.arange(0, 5, 1)
>>> a.to_ndarray()
array([0, 1, 2, 3, 4])
>>> type(a.to_ndarray())
<class 'numpy.ndarray'>
to_parquet(prefix_path: str, dataset: str = 'array', mode: Literal['truncate', 'append'] = 'truncate', compression: str | None = None) str[source]

Save the pdarray to Parquet. The result is a collection of files, one file per locale of the arkouda server, where each filename starts with prefix_path. Each locale saves its chunk of the array to its corresponding file.

Parameters:
  • prefix_path (str) – Directory and filename prefix that all output files share

  • dataset (str) – Name of the dataset to create in files (must not already exist)

  • mode ({'truncate', 'append'}) – By default, truncate (overwrite) output files, if they exist. If ‘append’, attempt to create new dataset in existing files.

  • compression (str (Optional)) – (None | “snappy” | “gzip” | “brotli” | “zstd” | “lz4”) Sets the compression type used with Parquet files

Return type:

string message indicating result of save operation

Raises:

RuntimeError – Raised if a server-side error is thrown saving the pdarray

Notes

  • The prefix_path must be visible to the arkouda server and the user must

have write permission. - Output files have names of the form <prefix_path>_LOCALE<i>, where <i> ranges from 0 to numLocales for file_type=’distribute’. - ‘append’ write mode is supported, but is not efficient. - If any of the output files already exist and the mode is ‘truncate’, they will be overwritten. If the mode is ‘append’ and the number of output files is less than the number of locales or a dataset with the same name already exists, a RuntimeError will result. - Any file extension can be used.The file I/O does not rely on the extension to determine the file format.

Examples

>>> import arkouda as ak
>>> a = ak.arange(25)

Saving without an extension >>> a.to_parquet(‘path/prefix’, dataset=’array’) # doctest: +SKIP Saves the array to numLocales HDF5 files with the name cwd/path/name_prefix_LOCALE####

Saving with an extension (HDF5) >>> a.to_parqet(‘path/prefix.parquet’, dataset=’array’) # doctest: +SKIP Saves the array to numLocales HDF5 files with the name cwd/path/name_prefix_LOCALE####.parquet where #### is replaced by each locale number

tolist() List[arkouda.numpy.dtypes.numeric_scalars][source]

Convert the array to a list, transferring array data from the Arkouda server to client-side Python. Note: if the pdarray size exceeds client.maxTransferBytes, a RuntimeError is raised.

Returns:

A list with the same data as the pdarray

Return type:

List[numeric_scalars]

Raises:

RuntimeError – Raised if there is a server-side error thrown, if the pdarray size exceeds the built-in client.maxTransferBytes size limit, or if the bytes received does not match expected number of bytes

Notes

The number of bytes in the array cannot exceed client.maxTransferBytes, otherwise a RuntimeError will be raised. This is to protect the user from overflowing the memory of the system on which the Python client is running, under the assumption that the server is running on a distributed system with much more memory than the client. The user may override this limit by setting client.maxTransferBytes to a larger value, but proceed with caution.

See also

to_ndarray

Examples

>>> import arkouda as ak
>>> a = ak.arange(0, 5, 1)
>>> a.tolist()
[0, 1, 2, 3, 4]
>>> type(a.tolist())
<class 'list'>
transfer(hostname: str, port: arkouda.numpy.dtypes.int_scalars)[source]

Send a pdarray to a different Arkouda server.

Parameters:
  • hostname (str) – The hostname where the Arkouda server intended to receive the pdarray is running.

  • port (int_scalars) – The port to send the array over. This needs to be an open port (i.e., not one that the Arkouda server is running on). This will open up numLocales ports, each of which in succession, so will use ports of the range {port..(port+numLocales)} (e.g., running an Arkouda server of 4 nodes, port 1234 is passed as port, Arkouda will use ports 1234, 1235, 1236, and 1237 to send the array data). This port much match the port passed to the call to ak.receive_array().

Return type:

A message indicating a complete transfer

Raises:
  • ValueError – Raised if the op is not within the pdarray.BinOps set

  • TypeError – Raised if other is not a pdarray or the pdarray.dtype is not a supported dtype

unregister() None[source]

Unregister a pdarray in the arkouda server which was previously registered using register() and/or attahced to using attach().

Raises:

RuntimeError – Raised if the server could not find the internal name/symbol to remove

See also

register, unregister, is_registered, unregister_pdarray_by_name, list_registry

Notes

Registered names/pdarrays in the server are immune to deletion until they are unregistered.

Examples

>>> import arkouda as ak
>>> a = ak.zeros(3)
>>> a.register("my_zeros")
array([0.00000000000000000 0.00000000000000000 0.00000000000000000])

potentially disconnect from server and reconnect to server >>> b = ak.attach(“my_zeros”) >>> b.unregister()

update_hdf(prefix_path: str, dataset: str = 'array', repack: bool = True)[source]

Overwrite the dataset with the name provided with this pdarray. If the dataset does not exist it is added.

Parameters:
  • prefix_path (str) – Directory and filename prefix that all output files share

  • dataset (str) – Name of the dataset to create in files

  • repack (bool) – Default: True HDF5 does not release memory on delete. When True, the inaccessible data (that was overwritten) is removed. When False, the data remains, but is inaccessible. Setting to false will yield better performance, but will cause file sizes to expand.

Return type:

str - success message if successful

Raises:

RuntimeError – Raised if a server-side error is thrown saving the pdarray

Notes

  • If file does not contain File_Format attribute to indicate how it was saved, the file name is checked for _LOCALE#### to determine if it is distributed.

  • If the dataset provided does not exist, it will be added

value_counts()[source]

Count the occurrences of the unique values of self.

Returns:

unique_valuespdarray

The unique values, sorted in ascending order

countspdarray, int64

The number of times the corresponding unique value occurs

Return type:

pdarray, pdarray|int64

Examples

>>> import arkouda as ak
>>> ak.array([2, 0, 2, 4, 0, 0]).value_counts()
(array([0 2 4]), array([3 2 1]))
var(ddof: arkouda.numpy.dtypes.int_scalars = 0, axis: int | Tuple[int, Ellipsis] | None = None, keepdims: bool | None = False) numpy.float64 | pdarray[source]

Return the variance of values in the array.

Parameters:
  • ddof (int_scalars) – “Delta Degrees of Freedom” used in calculating var

  • axis (int, Tuple[int, ...], optional, default = None) – The axis or axes along which to do the operation If None, the computation is done across the entire array.

  • keepdims (bool, optional, default = False) – Whether to keep the singleton dimension(s) along axis in the result.

Returns:

The scalar variance of the array, or the variance along the axis/axes if supplied

Return type:

Union[np.float64, pdarray]

Examples

>>> import arkouda as ak
>>> a = ak.arange(10)
>>> ak.var(a)
np.float64(8.25)
>>> a.var()
np.float64(8.25)
>>> a = ak.arange(10).reshape(2,5)
>>> a.var(axis=0)
array([6.25 6.25 6.25 6.25 6.25])
>>> ak.var(a,axis=0)
array([6.25 6.25 6.25 6.25 6.25])
>>> a.var(axis=1)
array([2.00000000000000000 2.00000000000000000])
>>> ak.var(a,axis=1)
array([2.00000000000000000 2.00000000000000000])
Raises:
  • TypeError – Raised if pda is not a pdarray instance

  • ValueError – Raised if the ddof >= pdarray size

  • RuntimeError – Raised if there’s a server-side error thrown

See also

mean, std

Notes

The variance is the average of the squared deviations from the mean, i.e., var = mean((x - x.mean())**2).

The mean is normally calculated as x.sum() / N, where N = len(x). If, however, ddof is specified, the divisor N - ddof is used instead. In standard statistical practice, ddof=1 provides an unbiased estimator of the variance of a hypothetical infinite population. ddof=0 provides a maximum likelihood estimate of the variance for normally distributed variables.

arkouda.numpy.percentile(a: arkouda.numpy.pdarrayclass.pdarray, q: arkouda.numpy.dtypes.numeric_scalars | Tuple[arkouda.numpy.dtypes.numeric_scalars] | numpy.ndarray | None = 0.5, axis: arkouda.numpy.dtypes.int_scalars | Tuple[arkouda.numpy.dtypes.int_scalars, Ellipsis] | None | None = None, method: str | None = 'linear', keepdims: bool = False) arkouda.numpy.dtypes.numeric_scalars | arkouda.numpy.pdarrayclass.pdarray[source]

Compute the q-th percentile of the data along the specified axis.

Parameters:
  • a (pdarray) – data whose percentile will be computed

  • q (pdarray, Tuple, or np.ndarray) – a scalar, tuple, or np.ndarray of q values for the computation. All values must be in the range 0 <= q <= 100

  • axis (None, int scalar, or tuple of int scalars) – the axis or axes along which the percentiles are computed. The default is None, which computes the percenntile along a flattened version of the array.

  • method (string) – one of “inverted_cdf,” “averaged_inverted_cdf”, “closest_observation”, “interpolated_inverted_cdf”, “hazen”, “weibull”, “linear”, ‘median_unbiased”, “normal_unbiased”, “lower”,” higher”, “midpoint”

  • keepdims (bool) – True if the degenerate axes are to be retained after slicing, False if not

Returns:

If q is a scalar and axis is None, the result is a scalar. If q is a scalar and axis is supplied, the result is a pdarray of rank len(axis) less than the rank of a. If q is an array and axis is None, the result is a pdarray of shape q.shape If q is an array and axis is None, the result is a pdarray of rank q.ndim + pda.ndim - len(axis). However, there is an intermediate result which is of rank q.ndim + pda.ndim. If this is not in the compiled ranks, an error will be thrown even if the final result would be in the compiled ranks.

Return type:

pdarray or scalar

Notes

np.percentile also supports the method “nearest,” however its behavior does not match the numpy documentation, so it’s not supported here. np.percentile also allows for weighted inputs, but only for the method “inverted_cdf.” That also is not supported here.

Examples

>>> import arkouda as ak
>>> a = ak.array([[1,2,3,4,5],[1,2,3,4,5]])
>>> q = 70
>>> ak.percentile(a,q,axis=None,method="linear")
np.float64(4.0)
>>> ak.percentile(a,q,axis=1,method="lower")
array([3.00000000... 3.00000000...])
>>> q = np.array([40,60])
>>> ak.percentile(a,q,axis=None,method="weibull")
array([2.40000000... 3.59999999...])
>>> a = ak.array([[1,2],[5,3]])
>>> ak.percentile(a,q,axis=0,method="hazen")
array([array([2.20000000... 2.29999999...])
    array([3.79999999... 2.69999999...])])
Raises:

ValueError – Raised if scalar q or any value of array q is outside the range [0,100] Raised if the method is not one of the 12 supported methods. Raised if the result would have a rank not in the compiled ranks.

arkouda.numpy.pi: float
arkouda.numpy.popcount(pda: pdarray) pdarray[source]

Find the population (number of bits set) for each integer in an array.

Parameters:

pda (pdarray, int64, uint64, bigint) – Input array (must be integral).

Returns:

The number of bits set (1) in each element

Return type:

pdarray

Raises:

TypeError – If input array is not int64, uint64, or bigint

Examples

>>> import arkouda as ak
>>> A = ak.arange(10)
>>> ak.popcount(A)
array([0 1 1 2 1 2 2 3 1 2])
arkouda.numpy.power(pda: pdarray, pwr: int | float | pdarray, where: arkouda.numpy.dtypes.bool_scalars | pdarray = True) pdarray[source]

Raises an array to a power. If where is given, the operation will only take place in the positions where the where condition is True.

Note: Our implementation of the where argument deviates from numpy. The difference in behavior occurs at positions where the where argument contains a False. In numpy, these position will have uninitialized memory (which can contain anything and will vary between runs). We have chosen to instead return the value of the original array in these positions.

Parameters:
  • pda (pdarray) – A pdarray of values that will be raised to a power (pwr)

  • pwr (integer, float, or pdarray) – The power(s) that pda is raised to

  • where (Boolean or pdarray) – This condition is broadcast over the input. At locations where the condition is True, the corresponding value will be raised to the respective power. Elsewhere, it will retain its original value. Default set to True.

Returns:

a pdarray of values raised to a power, under the boolean where condition.

Return type:

pdarray

Examples

>>> import arkouda as ak
>>> a = ak.arange(5)
>>> ak.power(a, 3)
array([0 1 8 27 64])
>>> ak.power(a, 3, a % 2 == 0)
array([0 1 8 3 64])
Raises:
  • TypeError – raised if pda is not a pdarray, or if pwe is not an int, float, or pdarray

  • ValueError – raised if pda and power are of incompatible dimensions

arkouda.numpy.promote_to_common_dtype(arrays: List[arkouda.numpy.pdarrayclass.pdarray]) Tuple[Any, List[arkouda.numpy.pdarrayclass.pdarray]][source]

Promote a list of pdarrays to a common dtype.

Parameters:

arrays (List[pdarray]) – List of pdarrays to promote

Returns:

The common dtype of the pdarrays and the list of pdarrays promoted to that dtype

Return type:

dtype, List[pdarray]

Raises:

TypeError – Raised if any pdarray is a non-numeric type

See also

pdarray.promote_dtype

Examples

>>> import arkouda as ak
>>> a = ak.arange(5)
>>> b = ak.ones(5, dtype=ak.float64)
>>> dtype, promoted = ak.promote_to_common_dtype([a, b])
>>> dtype
dtype('float64')
>>> all(isinstance(p, ak.pdarray) and p.dtype == dtype for p in promoted)
True
arkouda.numpy.putmask(A: arkouda.numpy.pdarrayclass.pdarray, mask: arkouda.numpy.pdarrayclass.pdarray, Values: arkouda.numpy.pdarrayclass.pdarray) None[source]

Overwrite elements of A with elements from B based upon a mask array. Similar to numpy.putmask, where mask = False, A retains its original value, but where mask = True, A is overwritten with the corresponding entry from Values.

This is similar to ak.where, except that (1) no new pdarray is created, and (2) Values does not have to be the same size as A and mask.

Parameters:
  • A (pdarray) – Value(s) used when mask is False (see Notes for allowed dtypes)

  • mask (pdarray) – Used to choose values from A or B, must be same size as A, and of type ak.bool_

  • Values (pdarray) – Value(s) used when mask is False (see Notes for allowed dtypes)

Examples

>>> import arkouda as ak
>>> a = ak.array(np.arange(10))
>>> ak.putmask (a,a>2,a**2)
>>> a
array([0 1 2 9 16 25 36 49 64 81])
>>> a = ak.array(np.arange(10))
>>> values = ak.array([3,2])
>>> ak.putmask (a,a>2,values)
>>> a
array([0 1 2 2 3 2 3 2 3 2])
Raises:

RuntimeError – Raised if mask is not same size as A, or if A.dtype and Values.dtype are not an allowed pair (see Notes for details).

Notes

A and mask must be the same size. Values can be any size.
Allowed dtypes for A and Values conform to types accepted by numpy putmask.
If A is ak.float64, Values can be ak.float64, ak.int64, ak.uint64, ak.bool_.
If A is ak.int64, Values can be ak.int64 or ak.bool_.
If A is ak.uint64, Values can be ak.uint64, or ak.bool_.
If A is ak.bool_, Values must be ak.bool_.

Only one conditional clause is supported e.g., n < 5, n > 1.

multi-dim pdarrays are now implemented.

arkouda.numpy.quantile(a: arkouda.numpy.pdarrayclass.pdarray, q: arkouda.numpy.dtypes.numeric_scalars | Tuple[arkouda.numpy.dtypes.numeric_scalars] | numpy.ndarray | arkouda.numpy.pdarrayclass.pdarray | None = 0.5, axis: arkouda.numpy.dtypes.int_scalars | Tuple[arkouda.numpy.dtypes.int_scalars, Ellipsis] | None | None = None, method: str | None = 'linear', keepdims: bool = False) arkouda.numpy.dtypes.numeric_scalars | arkouda.numpy.pdarrayclass.pdarray[source]

Compute the q-th quantile of the data along the specified axis.

Parameters:
  • a (pdarray) – data whose quantile will be computed

  • q (pdarray, Tuple, or np.ndarray) – a scalar, tuple, or np.ndarray of q values for the computation. All values must be in the range 0 <= q <= 1

  • axis (None, int scalar, or tuple of int scalars) – the axis or axes along which the quantiles are computed. The default is None, which computes the quantile along a flattened version of the array.

  • method (string) – one of “inverted_cdf,” “averaged_inverted_cdf”, “closest_observation”, “interpolated_inverted_cdf”, “hazen”, “weibull”, “linear”, ‘median_unbiased”, “normal_unbiased”, “lower”,” higher”, “midpoint”

  • keepdims (bool) – True if the degenerate axes are to be retained after slicing, False if not

Returns:

If q is a scalar and axis is None, the result is a scalar. If q is a scalar and axis is supplied, the result is a pdarray of rank len(axis) less than the rank of a. If q is an array and axis is None, the result is a pdarray of shape q.shape If q is an array and axis is None, the result is a pdarray of rank q.ndim + pda.ndim - len(axis). However, there is an intermediate result which is of rank q.ndim + pda.ndim. If this is not in the compiled ranks, an error will be thrown even if the final result would be in the compiled ranks.

Return type:

pdarray or scalar

Notes

np.quantile also supports the method “nearest,” however its behavior does not match the numpy documentation, so it’s not supported here. np.quantile also allows for weighted inputs, but only for the method “inverted_cdf.” That also is not supported here.

Examples

>>> import arkouda as ak
>>> a = ak.array([[1,2,3,4,5],[1,2,3,4,5]])
>>> q = 0.7
>>> ak.quantile(a,q,axis=None,method="linear")
np.float64(4.0)
>>> ak.quantile(a,q,axis=1,method="lower")
array([3.00000000... 3.00000000...])
>>> q = np.array([0.4,0.6])
>>> ak.quantile(a,q,axis=None,method="weibull")
array([2.40000000... 3.59999999...])
>>> a = ak.array([[1,2],[5,3]])
>>> ak.quantile(a,q,axis=0,method="hazen")
array([array([2.20000000... 2.29999999...])
    array([3.79999999... 2.69999999...])])
Raises:

ValueError – Raised if scalar q or any value of array q is outside the range [0,1] Raised if the method is not one of the 12 supported methods. Raised if the result would have a rank not in the compiled ranks.

arkouda.numpy.rad2deg(pda: arkouda.numpy.pdarrayclass.pdarray, where: bool | arkouda.numpy.pdarrayclass.pdarray = True) arkouda.numpy.pdarrayclass.pdarray[source]

Converts angles element-wise from radians to degrees.

Parameters:
  • pda (pdarray)

  • where (bool or pdarray, default=True) – This condition is broadcast over the input. At locations where the condition is True, the corresponding value will be converted from radians to degrees. Elsewhere, it will retain its original value. Default set to True.

Returns:

A pdarray containing an angle converted to degrees, from radians, for each element of the original pdarray

Return type:

pdarray

Raises:

TypeError – Raised if the parameter is not a pdarray

Examples

>>> import arkouda as ak
>>> a = ak.linspace(0,6.28,4)
>>> ak.rad2deg(a)
array([0.00000000... 119.939165... 239.878330... 359.817495...])
arkouda.numpy.randint(low: arkouda.numpy.dtypes.numeric_scalars, high: arkouda.numpy.dtypes.numeric_scalars, size: arkouda.numpy.dtypes.int_scalars | Tuple[arkouda.numpy.dtypes.int_scalars, Ellipsis] = 1, dtype=akint64, seed: arkouda.numpy.dtypes.int_scalars | None = None) arkouda.numpy.pdarrayclass.pdarray[source]

Generate a pdarray of randomized int, float, or bool values in a specified range bounded by the low and high parameters.

Parameters:
Returns:

Values drawn uniformly from the specified range having the desired dtype

Return type:

pdarray

Raises:
  • TypeError – Raised if dtype.name not in DTypes, size is not an int, low or high is not an int or float, or seed is not an int

  • ValueError – Raised if size < 0 or if high < low

Notes

Calling randint with dtype=float64 will result in uniform non-integral floating point values.

Ranges >= 2**64 in size is undefined behavior because it exceeds the maximum value that can be stored on the server (uint64)

Examples

>>> import arkouda as ak
>>> ak.randint(0, 10, 5, seed=1701)
array([6 5 1 6 3])
>>> ak.randint(0, 1, 3, seed=1701, dtype=ak.float64)
array([0.011410423448327005 0.73618171558685619 0.12367222192448891])
>>> ak.randint(0, 2, 5, seed=1701, dtype=ak.bool_)
array([False True False True False])
arkouda.numpy.random_strings_lognormal(logmean: arkouda.numpy.dtypes.numeric_scalars, logstd: arkouda.numpy.dtypes.numeric_scalars, size: arkouda.numpy.dtypes.int_scalars, characters: str = 'uppercase', seed: arkouda.numpy.dtypes.int_scalars | None = None) arkouda.numpy.strings.Strings[source]

Generate random strings with log-normally distributed lengths and with characters drawn from a specified set.

Parameters:
  • logmean (numeric_scalars) – The log-mean of the length distribution

  • logstd (numeric_scalars) – The log-standard-deviation of the length distribution

  • size (int_scalars) – The number of strings to generate

  • characters ((uppercase, lowercase, numeric, printable, binary)) – The set of characters to draw from

  • seed (int_scalars, optional) – Value used to initialize the random number generator

Returns:

The Strings object encapsulating a pdarray of random strings

Return type:

Strings

Raises:
  • TypeError – Raised if logmean is neither a float nor a int, logstd is not a float, seed is not an int, size is not an int, or if characters is not a str

  • ValueError – Raised if logstd <= 0 or size < 0

Notes

The lengths of the generated strings are distributed $Lognormal(\mu, \sigma^2)$, with \(\\mu = logmean\) and \(\\sigma = logstd\). Thus, the strings will have an average length of \(exp(\\mu + 0.5*\\sigma^2)\), a minimum length of zero, and a heavy tail towards longer strings.

Examples

>>> import arkouda as ak
>>> ak.random_strings_lognormal(2, 0.25, 5, seed=1)
array(['VWHJEX', 'BEBBXJHGM', 'RWOVKBUR', 'LNJCSDXD', 'NKEDQC'])
>>> ak.random_strings_lognormal(2, 0.25, 5, seed=1, characters='printable')
array(['eL96<O', ')o-GOe lR', ')PV yHf(', '._b3Yc&K', ',7Wjef'])
arkouda.numpy.random_strings_uniform(minlen: arkouda.numpy.dtypes.int_scalars, maxlen: arkouda.numpy.dtypes.int_scalars, size: arkouda.numpy.dtypes.int_scalars, characters: str = 'uppercase', seed: None | arkouda.numpy.dtypes.int_scalars = None) arkouda.numpy.strings.Strings[source]

Generate random strings with lengths uniformly distributed between minlen and maxlen, and with characters drawn from a specified set.

Parameters:
  • minlen (int_scalars) – The minimum allowed length of string

  • maxlen (int_scalars) – The maximum allowed length of string

  • size (int_scalars) – The number of strings to generate

  • characters ((uppercase, lowercase, numeric, printable, binary)) – The set of characters to draw from

  • seed (Union[None, int_scalars], optional) – Value used to initialize the random number generator

Returns:

The array of random strings

Return type:

Strings

Raises:

ValueError – Raised if minlen < 0, maxlen < minlen, or size < 0

Examples

>>> import arkouda as ak
>>> ak.random_strings_uniform(minlen=1, maxlen=5, seed=8675309, size=5)
array(['ECWO', 'WSS', 'TZG', 'RW', 'C'])
>>> ak.random_strings_uniform(minlen=1, maxlen=5, seed=8675309, size=5,
... characters='printable')
array(['2 .z', 'aom', '2d|', 'o(', 'M'])
arkouda.numpy.register_all(data: dict)[source]

Register all objects in the provided dictionary.

This function iterates through the dictionary data, registering each object with its corresponding name. It is useful for batch registering multiple objects in Arkouda.

Parameters:

data (dict) – A dictionary that maps the name to register the object to the object itself. For example, {“MyArray”: ak.array([0, 1, 2])}.

Examples

>>> import arkouda as ak
>>> data = { "array1": ak.array([0, 1, 2]), "array2": ak.array([3, 4, 5]) }
>>> ak.register_all(data)

After calling this function, “array1” and “array2” are registered in Arkouda, and can be accessed by their names. >>> ak.unregister_all([“array1”, “array2”])

arkouda.numpy.repeat(a: int | Sequence[int] | arkouda.numpy.pdarrayclass.pdarray, repeats: int | Sequence[int] | arkouda.numpy.pdarrayclass.pdarray, axis: None | int = None) arkouda.numpy.pdarrayclass.pdarray[source]

Repeat each element of an array after themselves.

Parameters:
  • a (int, Sequence of int, or pdarray) – Input array.

  • repeats (int, Sequence of int, or pdarray) – The number of repetitions for each element. repeats is broadcasted to fit the shape of the given axis.

  • axis (int, optional) – The axis along which to repeat values. By default, use the flattened input array, and return a flat output array.

Returns:

Output array which has the same shape as a, except along the given axis.

Return type:

pdarray

Raises:
  • ValueError – Raised if repeats is not an int or a 1-dimensional array, or if it contains negative values, if its size does not match the input arrays size along axis.

  • RuntimeError – Raised if the operation fails server-side.

  • TypeError – Raised if axis anything but None or int, or if either a or repeats is invalid (the a and repeat cases should be impossible).

  • IndexError – Raised if axis is invalid for the given rank.

Examples

>>> import arkouda as ak
>>> ak.repeat(3, 4)
array([3 3 3 3])
>>> x = ak.array([[1,2],[3,4]])
>>> ak.repeat(x, 2)
array([1 1 2 2 3 3 4 4])
>>> ak.repeat(x, 3, axis=1)
array([array([1 1 1 2 2 2]) array([3 3 3 4 4 4])])
>>> ak.repeat(x, [1, 2], axis=0)
array([array([1 2]) array([3 4]) array([3 4])])
arkouda.numpy.resolve_scalar_dtype(val: object) str[source]

Try to infer what dtype arkouda_server should treat val as.

arkouda.numpy.result_type(*args)[source]

Determine the result dtype from one or more inputs, following NumPy’s promotion rules but extended to support Arkouda bigint semantics.

This function mirrors numpy.result_type for standard NumPy dtypes, scalars, and arrays, but additionally recognizes Arkouda bigint and bigint_ values, promoting them according to Arkouda-specific rules.

In mixed-type expressions, the following logic is applied:

  • Any presence of bigint or bigint_ promotes the result to:
    • float64 if any float is also present,

    • otherwise bigint.

  • Python integers first pass through Arkouda’s magnitude-aware dtype() routing, so extremely large integers may promote to bigint.

  • Booleans promote to bool as in NumPy.

  • Mixed signed/unsigned integers follow NumPy rules, except that a non-negative signed scalar combined with unsigned scalars promotes to the widest unsigned dtype.

  • All remaining cases defer to numpy.result_type.

Parameters:

*args (Any) – One or more dtype-like objects, scalars, NumPy arrays, Arkouda arrays, or any value accepted by numpy.result_type or Arkouda’s dtype() conversion.

Examples

>>> import arkouda as ak
>>> from arkouda.numpy import result_type, dtype

# bigint wins unless floats appear >>> result_type(dtype(“bigint”), dtype(“int64”)) dtype(bigint)

>>> result_type(dtype("bigint"), dtype("float64"))
dtype('float64')

# magnitude-aware routing: this becomes bigint, so result is bigint >>> result_type(2**100, 5) dtype(bigint)

# standard NumPy integer promotions >>> result_type(dtype(“int32”), dtype(“int64”)) dtype(‘int64’)

# unsigned with non-negative signed scalar → largest unsigned >>> result_type(np.uint32(3), 7) # 7 is non-negative signed scalar dtype(‘uint32’)

# float promotion >>> result_type(1.0, 5) dtype(‘float64’)

# boolean stays boolean >>> result_type(True, False) dtype(‘bool’)

arkouda.numpy.right_align(left, right)[source]

Map two arrays of sparse values to the 0-up index.

Map two arrays of sparse values to the 0-up index set implied by the right array, discarding values from left that do not appear in right.

Parameters:
  • left (pdarray or a sequence of pdarrays) – Left-hand identifiers

  • right (pdarray or a sequence of pdarrays) – Right-hand identifiers that define the index

Returns:

keeppdarray, bool

Logical index of left-hand values that survived

aligned(pdarray, pdarray)

Left and right arrays with values replaced by 0-up indices

Return type:

pdarray, (pdarray, pdarray)

arkouda.numpy.rotl(x, rot) pdarray[source]

Rotate bits of <x> to the left by <rot>.

Parameters:
Returns:

The rotated elements of x.

Return type:

pdarray

Raises:

TypeError – If input array is not int64 or uint64

Examples

>>> import arkouda as ak
>>> A = ak.arange(10)
>>> ak.rotl(A, A)
array([0 2 8 24 64 160 384 896 2048 4608])
arkouda.numpy.rotr(x, rot) pdarray[source]

Rotate bits of <x> to the left by <rot>.

Parameters:
Returns:

The rotated elements of x.

Return type:

pdarray

Raises:

TypeError – If input array is not int64 or uint64

Examples

>>> import arkouda as ak
>>> A = ak.arange(10)
>>> ak.rotr(1024 * A, A)
array([0 512 512 384 256 160 96 56 32 18])
arkouda.numpy.round(pda: arkouda.numpy.pdarrayclass.pdarray, where: bool | arkouda.numpy.pdarrayclass.pdarray = True) arkouda.numpy.pdarrayclass.pdarray[source]

Return the element-wise rounding of the array.

Parameters:
  • pda (pdarray)

  • where (bool or pdarray, default=True) – This condition is applied over the input. At locations where the condition is True, the corresponding value will be acted on by the function. Elsewhere, it will retain its original value. Default set to True.

Returns:

A pdarray containing input array elements rounded to the nearest integer

Return type:

pdarray

Raises:

TypeError – Raised if the parameter is not a pdarray

Examples

>>> import arkouda as ak
>>> ak.round(ak.array([1.1, 2.5, 3.14159]))
array([1.00000000... 3.00000000... 3.00000000...])
arkouda.numpy.scalar_array(value: arkouda.numpy.dtypes.numeric_scalars | arkouda.numpy.dtypes.bool_scalars, dtype: numpy.dtype | type | str | arkouda.numpy.dtypes.bigint | None = None) arkouda.numpy.pdarrayclass.pdarray[source]

Create a pdarray from a single scalar value.

Parameters:
  • value (numeric_scalars) – Value to create pdarray from

  • dtype (np.dtype, type, str, bigint, or None) – The data type of the created array.

Returns:

pdarray with a single element

Return type:

pdarray

Examples

>>> import arkouda as ak
>>> ak.scalar_array(5)
array([5])
>>> ak.scalar_array(7.0)
array([7.00000000000000000])
Raises:

RuntimeError – Raised if value cannot be cast as dtype

class arkouda.numpy.sctypeDict

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s

(key, value) pairs

dict(iterable) -> new dictionary initialized as if via:

d = {} for k, v in iterable:

d[k] = v

dict(**kwargs) -> new dictionary initialized with the name=value pairs

in the keyword argument list. For example: dict(one=1, two=2)

clear()

Remove all items from the dict.

copy()

Return a shallow copy of the dict.

fromkeys(iterable, value=None, /)

Create a new dictionary with keys from iterable and values set to value.

get(key, default=None, /)

Return the value for key if key is in the dictionary, else default.

items()

Return a set-like object providing a view on the dict’s items.

keys()

Return a set-like object providing a view on the dict’s keys.

pop(*args, **kwargs)

D.pop(k[,d]) -> v, remove specified key and return the corresponding value.

If the key is not found, return the default if given; otherwise, raise a KeyError.

popitem()

Remove and return a (key, value) pair as a 2-tuple.

Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.

setdefault(key, default=None, /)

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

update(*args, **kwargs)

D.update([E, ]**F) -> None. Update D from mapping/iterable E and F. If E is present and has a .keys() method, then does: for k in E.keys(): D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values()

Return an object providing a view on the dict’s values.

arkouda.numpy.search_intervals(vals, intervals, tiebreak=None, hierarchical=True)[source]

Return the index of the best interval containing each query value.

Given an array of query vals and non-overlapping, closed intervals, return the index of the best (see tiebreak) interval containing each query value, or -1 if not present in any interval.

Parameters:
  • vals ((sequence of) pdarray(int, uint, float)) – Values to search for in intervals. If multiple arrays, each “row” is an item.

  • intervals (2-tuple of (sequences of) pdarrays) – Non-overlapping, half-open intervals, as a tuple of (lower_bounds_inclusive, upper_bounds_exclusive) Must have same dtype(s) as vals.

  • tiebreak ((optional) pdarray, numeric) – When a value is present in more than one interval, the interval with the lowest tiebreak value will be chosen. If no tiebreak is given, the first containing interval will be chosen.

  • hierarchical (boolean) – When True, sequences of pdarrays will be treated as components specifying a single dimension (i.e. hierarchical) When False, sequences of pdarrays will be specifying multi-dimensional intervals

Returns:

idx – Index of interval containing each query value, or -1 if not found

Return type:

pdarray(int64)

Notes

The return idx satisfies the following condition:

present = idx > -1 ((intervals[0][idx[present]] <= vals[present]) &

(intervals[1][idx[present]] >= vals[present])).all()

Examples

>>> import arkouda as ak
>>> starts = (ak.array([0, 5]), ak.array([0, 11]))
>>> ends = (ak.array([5, 9]), ak.array([10, 20]))
>>> vals = (ak.array([0, 0, 2, 5, 5, 6, 6, 9]), ak.array([0, 20, 1, 5, 15, 0, 12, 30]))
>>> ak.numpy.alignment.search_intervals(vals, (starts, ends), hierarchical=False)
array([0 -1 0 0 1 -1 1 -1])
>>> ak.numpy.alignment.search_intervals(vals, (starts, ends))
array([0 0 0 0 1 1 1 -1])
>>> bi_starts = ak.bigint_from_uint_arrays([ak.cast(a, ak.uint64) for a in starts])
>>> bi_ends = ak.bigint_from_uint_arrays([ak.cast(a, ak.uint64) for a in ends])
>>> bi_vals = ak.bigint_from_uint_arrays([ak.cast(a, ak.uint64) for a in vals])
>>> bi_starts, bi_ends, bi_vals
(array([0 92233720368547758091]),
array([92233720368547758090 166020696663385964564]),
array([0 20 36893488147419103233 92233720368547758085 92233720368547758095
110680464442257309696 110680464442257309708 166020696663385964574]))
>>> ak.numpy.alignment.search_intervals(bi_vals, (bi_starts, bi_ends))
array([0 0 0 0 1 1 1 -1])
arkouda.numpy.searchsorted(a: arkouda.numpy.pdarrayclass.pdarray, v: arkouda.numpy.dtypes.int_scalars | arkouda.numpy.dtypes.float64 | arkouda.numpy.dtypes.bigint | arkouda.numpy.pdarrayclass.pdarray, side: Literal['left', 'right'] = 'left', x2_sorted: bool = False) int | arkouda.numpy.pdarrayclass.pdarray[source]

Find indices where elements should be inserted to maintain order.

Find the indices into a sorted array a such that, if the corresponding elements in v were inserted before the indices, the order of a would be preserved.

Parameters:
  • a (pdarray) – 1-D input array. Must be sorted in ascending order. sorter is not currently supported.

  • v (int_scalars, float64, bigint, or pdarray) – Values to insert into a. Can be a scalar or array-like.

  • side ({'left', 'right'}, default='left') – If ‘left’, the index of the first suitable location found is given. If ‘right’, return the last such index.

  • x2_sorted (bool, default=False) – If True, assumes that v (x2) is already sorted in ascending order. This can improve performance for large, sorted search arrays. If False, no assumption is made about the order of v.

Returns:

indices – If v is an array, returns an array of insertion points with the same shape. If v is a scalar, returns a single integer index.

Return type:

int or pdarray

Raises:
  • ValueError – If a has more than one dimension.

  • TypeError – If a has an unsupported dtype (i.e., not int64, uint64, bigint, or float64). If the dtype of a and v does not match

Examples

>>> import arkouda as ak
>>> a = ak.array([11, 12, 13, 14, 15])
>>> ak.searchsorted(a, 13)
2
>>> ak.searchsorted(a, 13, side='right')
3
>>> v = ak.array([-10, 20, 12, 13])
>>> ak.searchsorted(a, v)
array([0 5 1 2])
>>> v_sorted = ak.array([-10, 12, 13, 20])
>>> ak.searchsorted(a, v_sorted, x2_sorted=True)
array([0 1 2 5])
arkouda.numpy.setdiff1d(ar1: arkouda.pandas.groupbyclass.groupable, ar2: arkouda.pandas.groupbyclass.groupable, assume_unique: bool = False) arkouda.numpy.pdarrayclass.pdarray | arkouda.pandas.groupbyclass.groupable[source]

Find the set difference of two arrays.

Return the sorted, unique values in A that are not in B.

Parameters:
Returns:

Sorted 1D array/List of sorted pdarrays of values in ar1 that are not in ar2.

Return type:

pdarray/groupable

Raises:
  • TypeError – Raised if either ar1 or ar2 is not a pdarray

  • RuntimeError – Raised if the dtype of either pdarray is not supported

Notes

ak.setdiff1d is not supported for bool pdarrays

Examples

>>> import arkouda as ak
>>> a = ak.array([1, 2, 3, 2, 4, 1])
>>> b = ak.array([3, 4, 5, 6])
>>> ak.setdiff1d(a, b)
array([1 2])

Multi-Array Example

>>> a = ak.arange(1, 6)
>>> b = ak.array([1, 5, 3, 4, 2])
>>> c = ak.array([1, 4, 3, 2, 5])
>>> d = ak.array([1, 2, 3, 5, 4])
>>> multia = [a, a, a]
>>> multib = [b, c, d]
>>> ak.setdiff1d(multia, multib)
[array([2 4 5]), array([2 4 5]), array([2 4 5])]
arkouda.numpy.seterr(**kwargs: _ErrorMode) Dict[str, _ErrorMode][source]

Set how Arkouda handles floating-point errors.

Parameters:
  • divide ({'ignore', 'warn', 'raise', 'call', 'print', 'log'}, optional) – Behavior for the corresponding error category.

  • over ({'ignore', 'warn', 'raise', 'call', 'print', 'log'}, optional) – Behavior for the corresponding error category.

  • under ({'ignore', 'warn', 'raise', 'call', 'print', 'log'}, optional) – Behavior for the corresponding error category.

  • invalid ({'ignore', 'warn', 'raise', 'call', 'print', 'log'}, optional) – Behavior for the corresponding error category.

Returns:

The previous settings.

Return type:

dict

Notes

This is a scaffold API. It does not change backend behavior yet; it only records the desired policy so future operations can consult it.

arkouda.numpy.seterrcall(func: Callable[[str, str], None] | None) Callable[[str, str], None] | None[source]

Set the callable invoked when an error category is set to ‘call’.

Parameters:

func (callable or None) – Function of signature (errtype: str, message: str) -> None. Pass None to clear.

Returns:

The previous callable.

Return type:

callable or None

Notes

This is a stub for API compatibility. Arkouda does not currently invoke this callable; it is stored for future use.

arkouda.numpy.setxor1d(ar1: arkouda.pandas.groupbyclass.groupable, ar2: arkouda.pandas.groupbyclass.groupable, assume_unique: bool = False) arkouda.numpy.pdarrayclass.pdarray | arkouda.pandas.groupbyclass.groupable[source]

Find the set exclusive-or (symmetric difference) of two arrays.

Return the sorted, unique values that are in only one (not both) of the input arrays.

Parameters:
Returns:

Sorted 1D array/List of sorted pdarrays of unique values that are in only one of the input arrays.

Return type:

pdarray/groupable

Raises:
  • TypeError – Raised if either ar1 or ar2 is not a groupable

  • RuntimeError – Raised if the dtype of either pdarray is not supported

Examples

>>> import arkouda as ak
>>> a = ak.array([1, 2, 3, 2, 4])
>>> b = ak.array([2, 3, 5, 7, 5])
>>> ak.setxor1d(a,b)
array([1 4 5 7])

Multi-Array Example

>>> a = ak.arange(1, 6)
>>> b = ak.array([1, 5, 3, 4, 2])
>>> c = ak.array([1, 4, 3, 2, 5])
>>> d = ak.array([1, 2, 3, 5, 4])
>>> multia = [a, a, a]
>>> multib = [b, c, d]
>>> ak.setxor1d(multia, multib)
[array([2 2 4 4 5 5]), array([2 5 2 4 4 5]), array([2 4 5 4 2 5])]
arkouda.numpy.shape(a: arkouda.numpy.pdarrayclass.pdarray | arkouda.numpy.strings.Strings | arkouda.numpy.dtypes.all_scalars) Tuple[source]

Return the shape of an array.

Parameters:

a (pdarray, Strings, or all_scalars) – Input array.

Returns:

The elements of the shape tuple give the lengths of the corresponding array dimensions.

Return type:

Tuple

Examples

>>> import arkouda as ak
>>> ak.shape(ak.eye(3,2))
(3, 2)
>>> ak.shape([[1, 3]])
(1, 2)
>>> ak.shape([0])
(1,)
>>> ak.shape(0)
()
arkouda.numpy.shares_memory(a, b)[source]

Return True if a and b share any Arkouda server-side buffers.

This is an Arkouda analogue of numpy.shares_memory with a simpler definition: it checks for identical backing buffer identities (same server object names).

Notes

  • Because Arkouda commonly materializes results (rather than views), aliasing is rare and usually only true when objects literally reference the same backing buffers.

  • For compound containers (e.g., SegArray, Strings, Categorical), we check all of their component buffers.

  • If you introduce true view semantics in the future, teach _ak_buffer_names to surface the base buffer name(s) and view descriptors, and compare bases.

class arkouda.numpy.short

Bases: numpy.signedinteger

Signed integer type, compatible with C short.

Character code:

'h'

Canonical name:

numpy.short

Alias on this platform (Linux x86_64):

numpy.int16: 16-bit signed integer (-32_768 to 32_767).

bit_count(/)

int16.bit_count() -> int

Computes the number of 1-bits in the absolute value of the input. Analogous to the builtin int.bit_count or popcount in C++.

>>> np.int16(127).bit_count()
7
>>> np.int16(-127).bit_count()
7
arkouda.numpy.sign(pda: arkouda.numpy.pdarrayclass.pdarray) arkouda.numpy.pdarrayclass.pdarray[source]

Return the element-wise sign of the array.

Parameters:

pda (pdarray)

Returns:

A pdarray containing sign values of the input array elements

Return type:

pdarray

Raises:

TypeError – Raised if the parameter is not a pdarray

Examples

>>> import arkouda as ak
>>> ak.sign(ak.array([-10, -5, 0, 5, 10]))
array([-1 -1 0 1 1])
class arkouda.numpy.signedinteger

Bases: numpy.integer

Abstract base class of all signed integer scalar types.

arkouda.numpy.sin(pda: arkouda.numpy.pdarrayclass.pdarray, where: bool | arkouda.numpy.pdarrayclass.pdarray = True) arkouda.numpy.pdarrayclass.pdarray[source]

Return the element-wise sine of the array.

Parameters:
  • pda (pdarray)

  • where (bool or pdarray, default=True) – This condition is broadcast over the input. At locations where the condition is True, the sine will be applied to the corresponding value. Elsewhere, it will retain its original value. Default set to True.

Returns:

A pdarray containing sin for each element of the original pdarray

Return type:

pdarray

Raises:

TypeError – Raised if the parameter is not a pdarray

Examples

>>> import arkouda as ak
>>> a = ak.linspace(-1.5,0.75,4)
>>> ak.sin(a)
array([-0.99749498... -0.68163876... 0.00000000... 0.68163876...])
class arkouda.numpy.single

Bases: numpy.floating

Single-precision floating-point number type, compatible with C float.

Character code:

'f'

Canonical name:

numpy.single

Alias on this platform (Linux x86_64):

numpy.float32: 32-bit-precision floating-point number type: sign bit, 8 bits exponent, 23 bits mantissa.

as_integer_ratio(/)

single.as_integer_ratio() -> (int, int)

Return a pair of integers, whose ratio is exactly equal to the original floating point number, and with a positive denominator. Raise OverflowError on infinities and a ValueError on NaNs.

>>> np.single(10.0).as_integer_ratio()
(10, 1)
>>> np.single(0.0).as_integer_ratio()
(0, 1)
>>> np.single(-.25).as_integer_ratio()
(-1, 4)
is_integer(/)

single.is_integer() -> bool

Return True if the floating point number is finite with integral value, and False otherwise.

Added in version 1.22.

>>> np.single(-2.0).is_integer()
True
>>> np.single(3.2).is_integer()
False
arkouda.numpy.sinh(pda: arkouda.numpy.pdarrayclass.pdarray, where: bool | arkouda.numpy.pdarrayclass.pdarray = True) arkouda.numpy.pdarrayclass.pdarray[source]

Return the element-wise hyperbolic sine of the array.

Parameters:
  • pda (pdarray)

  • where (bool or pdarray, default=True) – This condition is broadcast over the input. At locations where the condition is True, the hyperbolic sine will be applied to the corresponding value. Elsewhere, it will retain its original value. Default set to True.

Returns:

A pdarray containing hyperbolic sine for each element of the original pdarray

Return type:

pdarray

Raises:

TypeError – Raised if the parameter is not a pdarray

Examples

>>> import arkouda as ak
>>> a = ak.linspace(-0.9,0.7,4)
>>> ak.sinh(a)
array([-1.02651672... -0.37493812... 0.16743934... 0.75858370...])
arkouda.numpy.sort(pda: arkouda.numpy.pdarrayclass.pdarray, algorithm: SortingAlgorithm = SortingAlgorithm.RadixSortLSD, axis: arkouda.numpy.dtypes.int_scalars = -1) arkouda.numpy.pdarrayclass.pdarray[source]

Return a sorted copy of the array. Only sorts numeric arrays; for Strings, use argsort.

Parameters:
  • pda (pdarray) – The array to sort (int64, uint64, or float64)

  • algorithm (SortingAlgorithm, default=SortingAlgorithm.RadixSortLSD) – The algorithm to be used for sorting the arrays.

  • axis (int_scalars, default=-1) – The axis to sort over. Setting to -1 means that it will sort over axis = ndim - 1.

Returns:

The sorted copy of pda

Return type:

pdarray

Raises:
  • TypeError – Raised if the parameter is not a pdarray

  • ValueError – Raised if sort attempted on a pdarray with an unsupported dtype such as bool

See also

argsort

Notes

Uses a least-significant-digit radix sort, which is stable and resilient to non-uniformity in data but communication intensive.

Examples

>>> import arkouda as ak
>>> a = ak.randint(0, 10, 10, seed=1)
>>> a
array([7 9 5 1 4 1 8 5 5 0])
>>> sorted = ak.sort(a)
>>> sorted
array([0 1 1 4 5 5 5 7 8 9])
arkouda.numpy.sqrt(pda: pdarray, where: arkouda.numpy.dtypes.bool_scalars | pdarray = True) pdarray[source]

Takes the square root of array. If where is given, the operation will only take place in the positions where the where condition is True.

Parameters:
  • pda (pdarray) – A pdarray of values the square roots of which will be computed

  • where (Boolean or pdarray) – This condition is broadcast over the input. At locations where the condition is True, the corresponding value will be square rooted. Elsewhere, it will retain its original value. Default set to True.

Returns:

a pdarray of square roots of the original values, or the original values themselves, subject to the boolean where condition.

Return type:

pdarray

Examples

>>> import arkouda as ak
>>> a = ak.arange(5)
>>> ak.sqrt(a)
array([0.00000000000000000 1.00000000000000000 1.4142135623730951
         1.7320508075688772 2.00000000000000000])
>>> ak.sqrt(a, ak.array([True, True, False, False, True]))
array([0.00000000000000000 1.00000000000000000 2.00000000000000000
         3.00000000000000000 2.00000000000000000])
Raises:

TypeError – raised if pda is not a pdarray of ak.int64 or ak.float64

Notes

Square roots of negative numbers are returned as nan.

arkouda.numpy.square(pda: arkouda.numpy.pdarrayclass.pdarray, where: bool | arkouda.numpy.pdarrayclass.pdarray = True) arkouda.numpy.pdarrayclass.pdarray[source]

Return the element-wise square of the array.

Parameters:
  • pda (pdarray)

  • where (bool or pdarray, default=True) – This condition is applied over the input. At locations where the condition is True, the corresponding value will be acted on by the function. Elsewhere, it will retain its original value. Default set to True.

Returns:

A pdarray containing square values of the input array elements

Return type:

pdarray

Raises:

TypeError – Raised if the parameter is not a pdarray

Examples

>>> import arkouda as ak
>>> ak.square(ak.arange(1,5))
array([1 4 9 16])
arkouda.numpy.squeeze(x: arkouda.numpy.pdarrayclass.pdarray | arkouda.numpy.dtypes.numeric_scalars | arkouda.numpy.dtypes.bool_scalars, /, axis: None | arkouda.numpy.dtypes.int_scalars | Tuple[arkouda.numpy.dtypes.int_scalars, Ellipsis] = None) arkouda.numpy.pdarrayclass.pdarray[source]

Remove degenerate (size one) dimensions from an array.

Parameters:
  • x (pdarray) – The array to squeeze

  • axis (int or Tuple[int, ...]) – The axis or axes to squeeze (must have a size of one). If axis = None, all dimensions of size 1 will be squeezed.

Returns:

A copy of x with the dimensions specified in the axis argument removed.

Return type:

pdarray

Raises:

RuntimeError – Raised if operation fails server-side.

Examples

>>> import arkouda as ak
>>> x = ak.arange(10).reshape((1, 10, 1))
>>> x.shape
(1, 10, 1)
>>> ak.squeeze(x, axis=None).shape
(10,)
>>> ak.squeeze(x, axis=2).shape
(1, 10)
>>> ak.squeeze(x, axis=(0, 2)).shape
(10,)
arkouda.numpy.standard_normal(size: arkouda.numpy.dtypes.int_scalars, seed: None | arkouda.numpy.dtypes.int_scalars = None) arkouda.numpy.pdarrayclass.pdarray[source]

Draw real numbers from the standard normal distribution.

Parameters:
  • size (int_scalars) – The number of samples to draw (size of the returned array)

  • seed (int_scalars) – Value used to initialize the random number generator

Returns:

The array of random numbers

Return type:

pdarray

Raises:
  • TypeError – Raised if size is not an int

  • ValueError – Raised if size < 0

See also

randint

Notes

For random samples from \(N(\\mu, \\sigma^2)\), use:

(sigma * standard_normal(size)) + mu

Examples

>>> import arkouda as ak
>>> ak.standard_normal(3,1)
array([-0.68586185091150265 1.1723810583573377 0.5675841071420...])
class arkouda.numpy.str_

A unicode string.

This type strips trailing null codepoints.

>>> s = np.str_("abc\x00")
>>> s
'abc'

Unlike the builtin str, this supports the python:bufferobjects, exposing its contents as UCS4:

>>> m = memoryview(np.str_("abc"))
>>> m.format
'3w'
>>> m.tobytes()
b'a\x00\x00\x00b\x00\x00\x00c\x00\x00\x00'
Character code:

'U'

T(*args, **kwargs)

Scalar attribute identical to the corresponding array attribute.

Please see ndarray.T.

all(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.all.

any(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.any.

argmax(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.argmax.

argmin(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.argmin.

argsort(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.argsort.

astype(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.astype.

base(*args, **kwargs)

Scalar attribute identical to the corresponding array attribute.

Please see ndarray.base.

byteswap(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.byteswap.

choose(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.choose.

clip(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.clip.

compress(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.compress.

conj(*args, **kwargs)
conjugate(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.conjugate.

copy(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.copy.

cumprod(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.cumprod.

cumsum(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.cumsum.

data(*args, **kwargs)

Pointer to start of data.

device(*args, **kwargs)
diagonal(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.diagonal.

dtype(*args, **kwargs)

Get array data-descriptor.

dump(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.dump.

dumps(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.dumps.

fill(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.fill.

flags(*args, **kwargs)

The integer value of flags.

flat(*args, **kwargs)

A 1-D view of the scalar.

flatten(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.flatten.

getfield(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.getfield.

imag(*args, **kwargs)

The imaginary part of the scalar.

item(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.item.

itemset(*args, **kwargs)
itemsize(*args, **kwargs)

The length of one element in bytes.

max(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.max.

mean(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.mean.

min(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.min.

nbytes(*args, **kwargs)
ndim(*args, **kwargs)

The number of array dimensions.

newbyteorder(*args, **kwargs)
nonzero(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.nonzero.

prod(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.prod.

ptp(*args, **kwargs)
put(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.put.

ravel(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.ravel.

real(*args, **kwargs)

The real part of the scalar.

repeat(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.repeat.

reshape(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.reshape.

resize(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.resize.

round(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.round.

searchsorted(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.searchsorted.

setfield(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.setfield.

setflags(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.setflags.

shape(*args, **kwargs)

Tuple of array dimensions.

size(*args, **kwargs)

The number of elements in the gentype.

sort(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.sort.

squeeze(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.squeeze.

std(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.std.

strides(*args, **kwargs)

Tuple of bytes steps in each dimension.

sum(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.sum.

swapaxes(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.swapaxes.

take(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.take.

to_device(*args, **kwargs)
tobytes(*args, **kwargs)
tofile(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.tofile.

tolist(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.tolist.

tostring(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.tostring.

trace(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.trace.

transpose(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.transpose.

var(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.var.

view(*args, **kwargs)

Scalar method identical to the corresponding array attribute.

Please see ndarray.view.

class arkouda.numpy.str_scalars

Bases: _NotIterable

Mixin to prevent iteration, without being compatible with Iterable.

That is, we could do:

def __iter__(self): raise TypeError()

But this would make users of this mixin duck type-compatible with collections.abc.Iterable - isinstance(foo, Iterable) would be True.

Luckily, we can instead prevent iteration by setting __iter__ to None, which is treated specially.

copy_with(params)
arkouda.numpy.take(a: arkouda.numpy.pdarrayclass.pdarray | arkouda.numpy.strings.Strings, indices: arkouda.numpy.dtypes.numeric_scalars | arkouda.numpy.pdarrayclass.pdarray | Iterable[arkouda.numpy.dtypes.numeric_scalars], axis: int | None = None) arkouda.numpy.pdarrayclass.pdarray[source]

Take elements from an array along an axis.

When axis is not None, this function does the same thing as “fancy” indexing (indexing arrays using arrays); however, it can be easier to use if you need elements along a given axis. A call such as np.take(arr, indices, axis=3) is equivalent to arr[:,:,:,indices,...].

Parameters:
  • a (pdarray or Strings) – The array from which to take elements

  • indices (numeric_scalars or pdarray or Iterable[numeric_scalars]) – The indices of the values to extract. Also allow scalars for indices.

  • axis (int, optional) – The axis over which to select values. By default, the flattened input array is used.

Returns:

The returned array has the same type as a.

Return type:

pdarray

Examples

>>> import arkouda as ak
>>> a = ak.array([4, 3, 5, 7, 6, 8])
>>> indices = [0, 1, 4]
>>> ak.take(a, indices)
array([4 3 6])
arkouda.numpy.tan(pda: arkouda.numpy.pdarrayclass.pdarray, where: bool | arkouda.numpy.pdarrayclass.pdarray = True) arkouda.numpy.pdarrayclass.pdarray[source]

Return the element-wise tangent of the array.

Parameters:
  • pda (pdarray)

  • where (bool or pdarray, default=True) – This condition is broadcast over the input. At locations where the condition is True, the tangent will be applied to the corresponding value. Elsewhere, it will retain its original value. Default set to True.

Returns:

A pdarray containing tangent for each element of the original pdarray

Return type:

pdarray

Raises:

TypeError – Raised if the parameter is not a pdarray

Examples

>>> import arkouda as ak
>>> a = ak.linspace(-1.5,0.75,4)
>>> ak.tan(a)
array([-14.1014199... -0.93159645... 0.00000000... 0.93159645...])
arkouda.numpy.tanh(pda: arkouda.numpy.pdarrayclass.pdarray, where: bool | arkouda.numpy.pdarrayclass.pdarray = True) arkouda.numpy.pdarrayclass.pdarray[source]

Return the element-wise hyperbolic tangent of the array.

Parameters:
  • pda (pdarray)

  • where (bool or pdarray, default=True) – This condition is broadcast over the input. At locations where the condition is True, the hyperbolic tangent will be applied to the corresponding value. Elsewhere, it will retain its original value. Default set to True.

Returns:

A pdarray containing hyperbolic tangent for each element of the original pdarray

Return type:

pdarray

Raises:

TypeError – Raised if the parameter is not a pdarray

Examples

>>> import arkouda as ak
>>> a = ak.linspace(-0.9,0.7,4)
>>> ak.tanh(a)
array([-0.71629787... -0.35107264... 0.16514041... 0.60436777...])
arkouda.numpy.tile(A: arkouda.numpy.pdarrayclass.pdarray, /, reps: int | Tuple[int, Ellipsis]) arkouda.numpy.pdarrayclass.pdarray[source]

Construct an array by repeating A the number of times given by reps.

If reps has length d, the result will have dimension of max(d, A.ndim).

If A.ndim < d, A is promoted to be d-dimensional by prepending new axes. So a shape (3,) array is promoted to (1, 3) for 2-D replication, or shape (1, 1, 3) for 3-D replication. If this is not the desired behavior, promote A to d-dimensions manually before calling this function.

If A.ndim > d, reps is promoted to A.ndim by prepending 1’s to it. Thus for an A of shape (2, 3, 4, 5), a reps of (2, 2) is treated as (1, 1, 2, 2).

Parameters:
  • A (pdarray) – The input pdarray to be tiled

  • reps (int or Tuple of int) – The number of repetitions of A along each axis.

Returns:

A new pdarray with the tiled data.

Return type:

pdarray

Examples

>>> import arkouda as ak
>>> a = ak.array([0, 1, 2])
>>> ak.tile(a, 2)
array([0 1 2 0 1 2])
>>> ak.tile(a, (2, 2))
array([array([0 1 2 0 1 2]) array([0 1 2 0 1 2])])
>>> ak.tile(a, (2, 1, 2))
array([array([array([0 1 2 0 1 2])]) array([array([0 1 2 0 1 2])])])
>>> b = ak.array([[1, 2], [3, 4]])
>>> ak.tile(b, 2)
array([array([1 2 1 2]) array([3 4 3 4])])
>>> ak.tile(b, (2, 1))
array([array([1 2]) array([3 4]) array([1 2]) array([3 4])])
>>> c = ak.array([1, 2, 3, 4])
>>> ak.tile(c, (4, 1))
array([array([1 2 3 4]) array([1 2 3 4]) array([1 2 3 4]) array([1 2 3 4])])
class arkouda.numpy.timedelta64

Bases: numpy.signedinteger

A timedelta stored as a 64-bit integer.

See arrays.datetime for more information.

Character code:

'm'

arkouda.numpy.timedelta_range(start=None, end=None, periods=None, freq=None, name=None, closed=None, **kwargs)[source]

Return a fixed frequency TimedeltaIndex, with day as the default frequency. Alias for ak.Timedelta(pd.timedelta_range(args)). Subject to size limit imposed by client.maxTransferBytes.

Parameters:
  • start (str or timedelta-like, default None) – Left bound for generating timedeltas.

  • end (str or timedelta-like, default None) – Right bound for generating timedeltas.

  • periods (int, default None) – Number of periods to generate.

  • freq (str or DateOffset, default 'D') – Frequency strings can have multiples, e.g. ‘5H’.

  • name (str, default None) – Name of the resulting TimedeltaIndex.

  • closed (str, default None) – Make the interval closed with respect to the given frequency to the ‘left’, ‘right’, or both sides (None).

Returns:

rng

Return type:

TimedeltaIndex

Notes

Of the four parameters start, end, periods, and freq, exactly three must be specified. If freq is omitted, the resulting TimedeltaIndex will have periods linearly spaced elements between start and end (closed on both sides).

To learn more about the frequency strings, please see this link.

arkouda.numpy.transpose(pda: arkouda.numpy.pdarrayclass.pdarray, axes: Tuple[arkouda.numpy.dtypes.int_scalars, Ellipsis] | None = None) arkouda.numpy.pdarrayclass.pdarray[source]

Compute the transpose of a matrix.

Parameters:
  • pda (pdarray)

  • axes (Tuple[int,...] Optional, defaults to None) – If specified, must be a tuple which contains a permutation of the axes of pda.

Returns:

the transpose of the input matrix For a 1-D array, this is the original array. For a 2-D array, this is the standard matrix transpose. For an n-D array, if axes are given, their order indicates how the axes are permuted. If axes is None, the axes are reversed.

Return type:

pdarray

Examples

>>> import arkouda as ak
>>> a = ak.array([[1,2,3,4,5],[1,2,3,4,5]])
>>> ak.transpose(a)
array([array([1 1]) array([2 2]) array([3 3]) array([4 4]) array([5 5])])
>>> z = ak.array(np.arange(27).reshape(3,3,3))
>>> ak.transpose(z,axes=(1,0,2))
array([array([array([0 1 2]) array([9 10 11]) array([18 19 20])]) array([array([3 4 5])
  array([12 13 14]) array([21 22 23])]) array([array([6 7 8]) array([15 16 17]) array([24 25 26])])])
Raises:
  • ValueError – Raised if axes is not a legitimate permutation of the axes of pda

  • TypeError – Raised if pda is not a pdarray, or if axes is neither a tuple nor None

arkouda.numpy.tril(pda: arkouda.numpy.pdarrayclass.pdarray, diag: arkouda.numpy.dtypes.int_scalars = 0) arkouda.numpy.pdarrayclass.pdarray[source]

Return a copy of the pda with the upper triangle zeroed out.

Parameters:
  • pda (pdarray)

  • diag (int_scalars, optional) –

    if diag = 0, zeros start just above the main diagonal
    if diag = 1, zeros start at the main diagonal
    if diag = 2, zeros start just below the main diagonal
    etc. Default set to 0.

Returns:

a copy of pda with zeros in the upper triangle

Return type:

pdarray

Examples

>>> import arkouda as ak
>>> a = ak.array([[1,2,3,4,5],[2,3,4,5,6],[3,4,5,6,7],[4,5,6,7,8],[5,6,7,8,9]])
>>> ak.tril(a,diag=4)
array([array([1 2 3 4 5]) array([2 3 4 5 6]) array([3 4 5 6 7])
array([4 5 6 7 8]) array([5 6 7 8 9])])
>>> ak.tril(a,diag=3)
array([array([1 2 3 4 0]) array([2 3 4 5 6]) array([3 4 5 6 7])
array([4 5 6 7 8]) array([5 6 7 8 9])])
>>> ak.tril(a,diag=2)
array([array([1 2 3 0 0]) array([2 3 4 5 0]) array([3 4 5 6 7])
array([4 5 6 7 8]) array([5 6 7 8 9])])
>>> ak.tril(a,diag=1)
array([array([1 2 0 0 0]) array([2 3 4 0 0]) array([3 4 5 6 0])
array([4 5 6 7 8]) array([5 6 7 8 9])])
>>> ak.tril(a,diag=0)
array([array([1 0 0 0 0]) array([2 3 0 0 0]) array([3 4 5 0 0])
array([4 5 6 7 0]) array([5 6 7 8 9])])

Notes

Server returns an error if rank of pda < 2

arkouda.numpy.triu(pda: arkouda.numpy.pdarrayclass.pdarray, diag: arkouda.numpy.dtypes.int_scalars = 0) arkouda.numpy.pdarrayclass.pdarray[source]

Return a copy of the pda with the lower triangle zeroed out.

Parameters:
  • pda (pdarray)

  • diag (int_scalars, default=0) –

    if diag = 0, zeros start just below the main diagonal
    if diag = 1, zeros start at the main diagonal
    if diag = 2, zeros start just above the main diagonal
    etc. Default set to 0.

Returns:

a copy of pda with zeros in the lower triangle

Return type:

pdarray

Examples

>>> import arkouda as ak
>>> a = ak.array([[1,2,3,4,5],[2,3,4,5,6],[3,4,5,6,7],[4,5,6,7,8],[5,6,7,8,9]])
>>> ak.triu(a,diag=0)
array([array([1 2 3 4 5]) array([0 3 4 5 6]) array([0 0 5 6 7])
array([0 0 0 7 8]) array([0 0 0 0 9])])
>>> ak.triu(a,diag=1)
array([array([0 2 3 4 5]) array([0 0 4 5 6]) array([0 0 0 6 7])
array([0 0 0 0 8]) array([0 0 0 0 0])])
>>> ak.triu(a,diag=2)
array([array([0 0 3 4 5]) array([0 0 0 5 6]) array([0 0 0 0 7])
array([0 0 0 0 0]) array([0 0 0 0 0])])
>>> ak.triu(a,diag=3)
array([array([0 0 0 4 5]) array([0 0 0 0 6]) array([0 0 0 0 0])
array([0 0 0 0 0]) array([0 0 0 0 0])])
>>> ak.triu(a,diag=4)
array([array([0 0 0 0 5]) array([0 0 0 0 0]) array([0 0 0 0 0])
array([0 0 0 0 0]) array([0 0 0 0 0])])

Notes

Server returns an error if rank of pda < 2

arkouda.numpy.trunc(pda: arkouda.numpy.pdarrayclass.pdarray, where: bool | arkouda.numpy.pdarrayclass.pdarray = True) arkouda.numpy.pdarrayclass.pdarray[source]

Return the element-wise truncation of the array.

Parameters:
  • pda (pdarray)

  • where (bool or pdarray, default=True) – This condition is applied over the input. At locations where the condition is True, the corresponding value will be acted on by the function. Elsewhere, it will retain its original value. Default set to True.

Returns:

A pdarray containing input array elements truncated to the nearest integer

Return type:

pdarray

Raises:

TypeError – Raised if the parameter is not a pdarray

Examples

>>> import arkouda as ak
>>> ak.trunc(ak.array([1.1, 2.5, 3.14159]))
array([1.00000000... 2.00000000... 3.00000000...])
arkouda.numpy.typename(char)

Return a description for the given data type code.

Parameters:

char (str) – Data type code.

Returns:

out – Description of the input data type code.

Return type:

str

See also

dtype

Examples

>>> import numpy as np
>>> typechars = ['S1', '?', 'B', 'D', 'G', 'F', 'I', 'H', 'L', 'O', 'Q',
...              'S', 'U', 'V', 'b', 'd', 'g', 'f', 'i', 'h', 'l', 'q']
>>> for typechar in typechars:
...     print(typechar, ' : ', np.typename(typechar))
...
S1  :  character
?  :  bool
B  :  unsigned char
D  :  complex double precision
G  :  complex long double precision
F  :  complex single precision
I  :  unsigned integer
H  :  unsigned short
L  :  unsigned long integer
O  :  object
Q  :  unsigned long long integer
S  :  string
U  :  unicode
V  :  void
b  :  signed char
d  :  double precision
g  :  long precision
f  :  single precision
i  :  integer
h  :  short
l  :  long integer
q  :  long long integer
class arkouda.numpy.ubyte

Bases: numpy.unsignedinteger

Unsigned integer type, compatible with C unsigned char.

Character code:

'B'

Canonical name:

numpy.ubyte

Alias on this platform (Linux x86_64):

numpy.uint8: 8-bit unsigned integer (0 to 255).

bit_count(/)

uint8.bit_count() -> int

Computes the number of 1-bits in the absolute value of the input. Analogous to the builtin int.bit_count or popcount in C++.

>>> np.uint8(127).bit_count()
7
class arkouda.numpy.uint

Bases: numpy.unsignedinteger

Unsigned signed integer type, 64bit on 64bit systems and 32bit on 32bit

systems.

Character code:

'L'

Canonical name:

numpy.uint

Alias on this platform (Linux x86_64):

numpy.uint64: 64-bit unsigned integer (0 to 18_446_744_073_709_551_615).

Alias on this platform (Linux x86_64):

numpy.uintp: Unsigned integer large enough to fit pointer, compatible with C uintptr_t.

bit_count(/)

uint64.bit_count() -> int

Computes the number of 1-bits in the absolute value of the input. Analogous to the builtin int.bit_count or popcount in C++.

>>> np.uint64(127).bit_count()
7
class arkouda.numpy.uint16

Bases: numpy.unsignedinteger

Unsigned integer type, compatible with C unsigned short.

Character code:

'H'

Canonical name:

numpy.ushort

Alias on this platform (Linux x86_64):

numpy.uint16: 16-bit unsigned integer (0 to 65_535).

bit_count(/)

uint16.bit_count() -> int

Computes the number of 1-bits in the absolute value of the input. Analogous to the builtin int.bit_count or popcount in C++.

>>> np.uint16(127).bit_count()
7
class arkouda.numpy.uint32

Bases: numpy.unsignedinteger

Unsigned integer type, compatible with C unsigned int.

Character code:

'I'

Canonical name:

numpy.uintc

Alias on this platform (Linux x86_64):

numpy.uint32: 32-bit unsigned integer (0 to 4_294_967_295).

bit_count(/)

uint32.bit_count() -> int

Computes the number of 1-bits in the absolute value of the input. Analogous to the builtin int.bit_count or popcount in C++.

>>> np.uint32(127).bit_count()
7
class arkouda.numpy.uint64

Bases: numpy.unsignedinteger

Unsigned signed integer type, 64bit on 64bit systems and 32bit on 32bit

systems.

Character code:

'L'

Canonical name:

numpy.uint

Alias on this platform (Linux x86_64):

numpy.uint64: 64-bit unsigned integer (0 to 18_446_744_073_709_551_615).

Alias on this platform (Linux x86_64):

numpy.uintp: Unsigned integer large enough to fit pointer, compatible with C uintptr_t.

bit_count(/)

uint64.bit_count() -> int

Computes the number of 1-bits in the absolute value of the input. Analogous to the builtin int.bit_count or popcount in C++.

>>> np.uint64(127).bit_count()
7
class arkouda.numpy.uint8

Bases: numpy.unsignedinteger

Unsigned integer type, compatible with C unsigned char.

Character code:

'B'

Canonical name:

numpy.ubyte

Alias on this platform (Linux x86_64):

numpy.uint8: 8-bit unsigned integer (0 to 255).

bit_count(/)

uint8.bit_count() -> int

Computes the number of 1-bits in the absolute value of the input. Analogous to the builtin int.bit_count or popcount in C++.

>>> np.uint8(127).bit_count()
7
class arkouda.numpy.uintc

Bases: numpy.unsignedinteger

Unsigned integer type, compatible with C unsigned int.

Character code:

'I'

Canonical name:

numpy.uintc

Alias on this platform (Linux x86_64):

numpy.uint32: 32-bit unsigned integer (0 to 4_294_967_295).

bit_count(/)

uint32.bit_count() -> int

Computes the number of 1-bits in the absolute value of the input. Analogous to the builtin int.bit_count or popcount in C++.

>>> np.uint32(127).bit_count()
7
class arkouda.numpy.uintp

Bases: numpy.unsignedinteger

Unsigned signed integer type, 64bit on 64bit systems and 32bit on 32bit

systems.

Character code:

'L'

Canonical name:

numpy.uint

Alias on this platform (Linux x86_64):

numpy.uint64: 64-bit unsigned integer (0 to 18_446_744_073_709_551_615).

Alias on this platform (Linux x86_64):

numpy.uintp: Unsigned integer large enough to fit pointer, compatible with C uintptr_t.

bit_count(/)

uint64.bit_count() -> int

Computes the number of 1-bits in the absolute value of the input. Analogous to the builtin int.bit_count or popcount in C++.

>>> np.uint64(127).bit_count()
7
class arkouda.numpy.ulonglong

Bases: numpy.unsignedinteger

Signed integer type, compatible with C unsigned long long.

Character code:

'Q'

bit_count(/)
arkouda.numpy.uniform(size: arkouda.numpy.dtypes.int_scalars | Tuple[arkouda.numpy.dtypes.int_scalars, Ellipsis], low: arkouda.numpy.dtypes.numeric_scalars = float(0.0), high: arkouda.numpy.dtypes.numeric_scalars = 1.0, seed: None | arkouda.numpy.dtypes.int_scalars = None) arkouda.numpy.pdarrayclass.pdarray[source]

Generate a pdarray with uniformly distributed random float values in a specified range.

Parameters:
  • size (Union[int_scalars, Tuple[int_scalars]) – The length or shape of the returned array

  • low (float_scalars) – The low value (inclusive) of the range, defaults to 0.0

  • high (float_scalars) – The high value (inclusive) of the range, defaults to 1.0

  • seed (int_scalars, optional) – Value used to initialize the random number generator

Returns:

Values drawn uniformly from the specified range

Return type:

pdarray

Raises:
  • TypeError – Raised if dtype.name not in DTypes, size is not an int, or if either low or high is not an int or float

  • ValueError – Raised if size < 0 or if high < low

Notes

The logic for uniform is delegated to the ak.randint method which is invoked with a dtype of float64

Examples

>>> import arkouda as ak
>>> ak.uniform(3,seed=1701)
array([0.011410423448327005 0.73618171558685619 0.12367222192448891])
>>> ak.uniform(size=3,low=0,high=5,seed=0)
array([0.30013431967121934 0.47383036230759112 1.0441791878997098])
arkouda.numpy.union1d(ar1: arkouda.pandas.groupbyclass.groupable, ar2: arkouda.pandas.groupbyclass.groupable) arkouda.pandas.groupbyclass.groupable[source]

Find the union of two arrays/List of Arrays.

Return the unique, sorted array of values that are in either of the two input arrays.

Parameters:
Returns:

Unique, sorted union of the input arrays.

Return type:

groupable

Raises:
  • TypeError – Raised if either ar1 or ar2 is not a groupable

  • RuntimeError – Raised if the dtype of either input is not supported

Examples

>>> import arkouda as ak

1D Example >>> ak.union1d(ak.array([-1, 0, 1]), ak.array([-2, 0, 2])) array([-2 -1 0 1 2])

Multi-Array Example >>> a = ak.arange(1, 6) >>> b = ak.array([1, 5, 3, 4, 2]) >>> c = ak.array([1, 4, 3, 2, 5]) >>> d = ak.array([1, 2, 3, 5, 4]) >>> multia = [a, a, a] >>> multib = [b, c, d] >>> ak.union1d(multia, multib) [array([1 2 2 3 4 4 5 5]), array([1 2 5 3 2 4 4 5]), array([1 2 4 3 5 4 2 5])]

arkouda.numpy.unregister(name: str) str[source]

Unregister an Arkouda object by its name.

This function sends a request to unregister the Arkouda object associated with the specified name. It returns a response message indicating the success or failure of the operation.

Parameters:

name (str) – The name of the object to unregister.

Returns:

A message indicating the result of the unregister operation.

Return type:

str

Raises:

RuntimeError – If the object associated with the given name does not exist or cannot be unregistered.

Examples

>>> import arkouda as ak

Unregister an existing object >>> obj = ak.array([1, 2, 3]) >>> registered_obj = obj.register(“my_array”) >>> response = ak.unregister(“my_array”) >>> print(response) Unregistered PDARRAY my_array

arkouda.numpy.unregister_all(names: List[str])[source]

Unregister all Arkouda objects associated with the provided names.

This function iterates through the list of names, unregistering each corresponding object from the Arkouda server.

Parameters:

names (List of str) – A list of registered names corresponding to Arkouda objects that should be unregistered.

Examples

>>> import arkouda as ak
>>> data = { "array1": ak.array([0, 1, 2]), "array2": ak.array([3, 4, 5]) }
>>> ak.register_all(data)

After calling this function, “array1” and “array2” are registered in Arkouda, and can be accessed by their names. >>> ak.unregister_all([“array1”, “array2”])

“arr1” and “arr2” are now unregistered

class arkouda.numpy.unsignedinteger

Bases: numpy.integer

Abstract base class of all unsigned integer scalar types.

arkouda.numpy.unsqueeze(p)[source]

Ensure that the input is returned as a list. If the input is a single pdarray, Strings, or Categorical object, wrap it in a list. Otherwise, return the input unchanged.

Parameters:

p (pdarray, Strings, Categorical, or Sequence) – The input object to be wrapped or returned as-is.

Returns:

A list containing the input, or the input itself if it is already a sequence.

Return type:

Sequence

Examples

>>> import arkouda as ak
>>> a = ak.array([1, 2, 3])
>>> unsqueeze(a)
[array([1 2 3])]
class arkouda.numpy.ushort

Bases: numpy.unsignedinteger

Unsigned integer type, compatible with C unsigned short.

Character code:

'H'

Canonical name:

numpy.ushort

Alias on this platform (Linux x86_64):

numpy.uint16: 16-bit unsigned integer (0 to 65_535).

bit_count(/)

uint16.bit_count() -> int

Computes the number of 1-bits in the absolute value of the input. Analogous to the builtin int.bit_count or popcount in C++.

>>> np.uint16(127).bit_count()
7
arkouda.numpy.value_counts(pda: arkouda.numpy.pdarrayclass.pdarray) tuple[arkouda.groupbyclass.groupable, arkouda.numpy.pdarrayclass.pdarray][source]

Count the occurrences of the unique values of an array.

Parameters:

pda (pdarray) – The array of values to count

Returns:

  • unique_values (pdarray, int64 or Strings) – The unique values, sorted in ascending order

  • counts (pdarray, int64) – The number of times the corresponding unique value occurs

Raises:

TypeError – Raised if the parameter is not a pdarray

See also

unique, histogram

Notes

This function differs from histogram() in that it only returns counts for values that are present, leaving out empty “bins”. This function delegates all logic to the unique() method where the return_counts parameter is set to True.

Examples

>>> import arkouda as ak
>>> A = ak.array([2, 0, 2, 4, 0, 0])
>>> ak.value_counts(A)
(array([0 2 4]), array([3 2 1]))
arkouda.numpy.vecdot(x1: arkouda.numpy.pdarrayclass.pdarray, x2: arkouda.numpy.pdarrayclass.pdarray, axis: int | None | None = None) arkouda.numpy.dtypes.numeric_scalars | arkouda.numpy.pdarrayclass.pdarray[source]

Computes the numpy-style vecdot product of two matrices. This differs from the vecdot function above. See https://numpy.org/doc/stable/reference/index.html.

Parameters:
  • x1 (pdarray)

  • x2 (pdarray)

  • axis (int, None, optional, default = None)

Returns:

x1 vecdot x2

Return type:

pdarray, numeric_scalar

Examples

>>> import arkouda as ak
>>> a = ak.array([[1,2,3,4,5],[1,2,3,4,5]])
>>> b = ak.array([[2,2,2,2,2],[2,2,2,2,2]])
>>> ak.vecdot(a,b)
array([30 30])
>>> ak.vecdot(b,a)
array([30 30])
Raises:

ValueError – Raised if x1 and x2 can not be broadcast to a compatible shape or if the last dimensions of x1 and x2 don’t match.

Notes

This matches the behavior of numpy vecdot, but as commented above, it is not the behavior of the deprecated vecdot, which calls the chapel-side vecdot function. This function only uses broadcast_to, broadcast_shapes, ak.sum, and the binops pdarray multiplication function. The last dimension of x1 and x2 must match, and it must be possible to broadcast them to a compatible shape. The deprecated vecdot can be computed via ak.vecdot(a,b,axis=0) on pdarrays of matching shape.

class arkouda.numpy.void

Bases: numpy.flexible

np.void(length_or_data, /, dtype=None)

Create a new structured or unstructured void scalar.

length_or_dataint, array-like, bytes-like, object

One of multiple meanings (see notes). The length or bytes data of an unstructured void. Or alternatively, the data to be stored in the new scalar when dtype is provided. This can be an array-like, in which case an array may be returned.

dtypedtype, optional

If provided the dtype of the new scalar. This dtype must be “void” dtype (i.e. a structured or unstructured void, see also defining-structured-types).

Added in version 1.24.

For historical reasons and because void scalars can represent both arbitrary byte data and structured dtypes, the void constructor has three calling conventions:

  1. np.void(5) creates a dtype="V5" scalar filled with five \0 bytes. The 5 can be a Python or NumPy integer.

  2. np.void(b"bytes-like") creates a void scalar from the byte string. The dtype itemsize will match the byte string length, here "V10".

  3. When a dtype= is passed the call is roughly the same as an array creation. However, a void scalar rather than array is returned.

Please see the examples which show all three different conventions.

>>> np.void(5)
np.void(b'\x00\x00\x00\x00\x00')
>>> np.void(b'abcd')
np.void(b'\x61\x62\x63\x64')
>>> np.void((3.2, b'eggs'), dtype="d,S5")
np.void((3.2, b'eggs'), dtype=[('f0', '<f8'), ('f1', 'S5')])
>>> np.void(3, dtype=[('x', np.int8), ('y', np.int8)])
np.void((3, 3), dtype=[('x', 'i1'), ('y', 'i1')])
Character code:

'V'

arkouda.numpy.vstack(tup: Sequence[arkouda.numpy.pdarrayclass.pdarray], *, dtype: str | type | None = None, casting: Literal['no', 'equiv', 'safe', 'same_kind', 'unsafe'] = 'same_kind') arkouda.numpy.pdarrayclass.pdarray[source]

Stack arrays in sequence vertically (row wise).

This is equivalent to concatenation along the first axis after 1-D arrays of shape (N,) have been reshaped to (1,N). Rebuilds arrays divided by vsplit.

This function makes most sense for arrays with up to 3 dimensions. For instance, for pixel-data with a height (first axis), width (second axis), and r/g/b channels (third axis). The functions concatenate, stack and block provide more general stacking and concatenation operations.

Parameters:
  • tup (sequence of pdarray) – The arrays must have the same shape along all but the first axis. 1-D arrays must have the same length. In the case of a single array_like input, it will be treated as a sequence of arrays; i.e., each element along the zeroth axis is treated as a separate array.

  • dtype (str or type, optional) – If provided, the destination array will have this dtype.

  • casting ({"no", "equiv", "safe", "same_kind", "unsafe"], optional) – Controls what kind of data casting may occur. Defaults to ‘same_kind’. Currently unused.

Returns:

The array formed by stacking the given arrays, will be at least 2-D.

Return type:

pdarray

See also

concatenate, stack, block, hstack, dstack, column_stack, hsplit, unstack

Examples

>>> import arkouda as ak
>>> a = ak.array([1, 2, 3])
>>> b = ak.array([4, 5, 6])
>>> ak.vstack((a, b))
array([array([1 2 3]) array([4 5 6])])
>>> a = ak.array([[1],[2],[3]])
>>> b = ak.array([[4],[5],[6]])
>>> ak.vstack((a, b))
array([array([1]) array([2]) array([3]) array([4]) array([5]) array([6])])
arkouda.numpy.where(condition: arkouda.numpy.pdarrayclass.pdarray, A: str | arkouda.numpy.dtypes.numeric_scalars | arkouda.numpy.pdarrayclass.pdarray | arkouda.numpy.strings.Strings | arkouda.pandas.categorical.Categorical, B: str | arkouda.numpy.dtypes.numeric_scalars | arkouda.numpy.pdarrayclass.pdarray | arkouda.numpy.strings.Strings | arkouda.pandas.categorical.Categorical) arkouda.numpy.pdarrayclass.pdarray | arkouda.numpy.strings.Strings | arkouda.pandas.categorical.Categorical[source]

Return an array with elements chosen from A and B based upon a conditioning array. As is the case with numpy.where, the return array consists of values from the first array (A) where the conditioning array elements are True and from the second array (B) where the conditioning array elements are False.

Parameters:
Returns:

Values chosen from A where the condition is True and B where the condition is False

Return type:

pdarray

Raises:
  • TypeError – Raised if the condition object is not a pdarray, if A or B is not an int, np.int64, float, np.float64, bool, pdarray, str, Strings, Categorical if pdarray dtypes are not supported or do not match, or multiple condition clauses (see Notes section) are applied

  • ValueError – Raised if the shapes of the condition, A, and B pdarrays are unequal

Examples

>>> import arkouda as ak
>>> a1 = ak.arange(1,10)
>>> a2 = ak.ones(9, dtype=np.int64)
>>> cond = a1 < 5
>>> ak.where(cond,a1,a2)
array([1 2 3 4 1 1 1 1 1])
>>> a1 = ak.arange(1,10)
>>> a2 = ak.ones(9, dtype=np.int64)
>>> cond = a1 == 5
>>> ak.where(cond,a1,a2)
array([1 1 1 1 5 1 1 1 1])
>>> a1 = ak.arange(1,10)
>>> a2 = 10
>>> cond = a1 < 5
>>> ak.where(cond,a1,a2)
array([1 2 3 4 10 10 10 10 10])
>>> s1 = ak.array([f'str {i}' for i in range(10)])
>>> s2 = 'str 21'
>>> cond = (ak.arange(10) % 2 == 0)
>>> ak.where(cond,s1,s2)
array(['str 0', 'str 21', 'str 2', 'str 21', 'str 4',
'str 21', 'str 6', 'str 21', 'str 8', 'str 21'])
>>> c1 = ak.Categorical(ak.array([f'str {i}' for i in range(10)]))
>>> c2 = ak.Categorical(ak.array([f'str {i}' for i in range(9, -1, -1)]))
>>> cond = (ak.arange(10) % 2 == 0)
>>> ak.where(cond,c1,c2)
array(['str 0', 'str 8', 'str 2', 'str 6', 'str 4',
'str 4', 'str 6', 'str 2', 'str 8', 'str 0'])

Notes

A and B must have the same dtype and only one conditional clause is supported e.g., n < 5, n > 1, which is supported in numpy is not currently supported in Arkouda

arkouda.numpy.zero_up(vals)[source]

Map an array of sparse values to 0-up indices.

Parameters:

vals (pdarray) – Array to map to dense index

Returns:

aligned – Array with values replaced by 0-up indices

Return type:

pdarray

arkouda.numpy.zeros(size: arkouda.numpy.dtypes.int_scalars | Tuple[arkouda.numpy.dtypes.int_scalars, Ellipsis] | str, dtype: numpy.dtype | type | str | arkouda.numpy.dtypes.bigint = float64, max_bits: int | None = None) arkouda.numpy.pdarrayclass.pdarray[source]

Create a pdarray filled with zeros.

Parameters:
  • size (int_scalars or tuple of int_scalars) – Size or shape of the array

  • dtype (all_scalars) – Type of resulting array, default ak.float64

  • max_bits (int) – Specifies the maximum number of bits; only used for bigint pdarrays Included for consistency, as zeros are represented as all zeros, regardless of the value of max_bits

Returns:

Zeros of the requested size or shape and dtype

Return type:

pdarray

Raises:
  • TypeError – Raised if the supplied dtype is not supported

  • RuntimeError – Raised if the size parameter is neither an int nor a str that is parseable to an int.

  • ValueError – Raised if the rank of the given shape is not in get_array_ranks() or is empty Raised if max_bits is not NONE and ndim does not equal 1

See also

ones, zeros_like

Examples

>>> import arkouda as ak
>>> ak.zeros(5, dtype=ak.int64)
array([0 0 0 0 0])
>>> ak.zeros(5, dtype=ak.float64)
array([0.00000000000000000 0.00000000000000000 0.00000000000000000
       0.00000000000000000 0.00000000000000000])
>>> ak.zeros(5, dtype=ak.bool_)
array([False False False False False])
arkouda.numpy.zeros_like(pda: arkouda.numpy.pdarrayclass.pdarray) arkouda.numpy.pdarrayclass.pdarray[source]

Create a zero-filled pdarray of the same size and dtype as an existing pdarray.

Parameters:

pda (pdarray) – Array to use for shape and dtype

Returns:

Equivalent to ak.zeros(pda.size, pda.dtype)

Return type:

pdarray

Raises:

TypeError – Raised if the pda parameter is not a pdarray.

See also

zeros, ones_like

Examples

>>> import arkouda as ak
>>> ak.zeros_like(ak.ones(5,dtype=ak.int64))
array([0 0 0 0 0])
>>> ak.zeros_like(ak.ones(5,dtype=ak.float64))
array([0.00000000000000000 0.00000000000000000 0.00000000000000000
       0.00000000000000000 0.00000000000000000])
>>> ak.zeros_like(ak.ones(5,dtype=ak.bool_))
array([False False False False False])