Arraykit

1.2.1 · active · verified Fri Apr 17

Arraykit provides low-level array utilities, often used by StaticFrame, for efficient data manipulation, type checking, and array transformations. It is currently at version 1.2.1 and follows an infrequent release cadence, often aligning with StaticFrame updates.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `astype_array` to convert various Python sequences into NumPy arrays with optional dtype specification. It also shows `is_objectable` for checking type compatibility with object arrays.

import numpy as np
from arraykit import astype_array

# Convert a list to a NumPy array with a specified dtype
data_int = [1, 2, 3, 4]
array_float = astype_array(data_int, dtype=np.float64)
print(f"Original list: {data_int}")
print(f"Converted array (float64): {array_float}, dtype: {array_float.dtype}\n")

# Convert mixed data; typically results in an object dtype if types are incompatible
mixed_data = [10, 'hello', 20.5, True]
array_object = astype_array(mixed_data)
print(f"Original mixed data: {mixed_data}")
print(f"Converted array (object): {array_object}, dtype: {array_object.dtype}\n")

# Using is_objectable
from arraykit import is_objectable
print(f"Is 'hello' objectable? {is_objectable('hello')}")
print(f"Is np.datetime64('2023-01-01') objectable? {is_objectable(np.datetime64('2023-01-01'))}")

view raw JSON →