Data Types (dtype)#
numpyCore Python provides NumPy-compatible data types for array elements.
Example#
import numpycore as np
# Create arrays with specific dtypes
arr_float = np.array([1, 2, 3], dtype=np.float64)
arr_int = np.array([1.5, 2.5, 3.5], dtype=np.int32)
# Check dtype
print(arr_float.dtype) # float64
print(arr_int.dtype) # int32
Numeric Types#
Type |
Alias |
Description |
|---|---|---|
float64 |
float_, double |
64-bit floating point |
float32 |
single |
32-bit floating point |
int64 |
int_, long |
64-bit signed integer |
int32 |
intc |
32-bit signed integer |
int16 |
short |
16-bit signed integer |
int8 |
byte |
8-bit signed integer |
uint64 |
ulong |
64-bit unsigned integer |
uint32 |
uintc |
32-bit unsigned integer |
uint16 |
ushort |
16-bit unsigned integer |
uint8 |
ubyte |
8-bit unsigned integer |
Complex Types#
Type |
Alias |
Description |
|---|---|---|
complex128 |
cdouble |
Complex with two 64-bit floats |
complex64 |
csingle |
Complex with two 32-bit floats |
Boolean Type#
Type |
Alias |
Description |
|---|---|---|
bool8 |
Boolean (True/False) |
dtype Attributes#
Attribute |
Description |
|---|---|
name |
Name of the data type |
kind |
Character code for data type kind |
itemsize |
Size of element in bytes |
byteorder |
Byte order (‘=’ native, ‘<’ little, ‘>’ big) |
char |
Single character type string |