Skip to main content
Version: Python

Deephaven Python dtypes

Deephaven defines its Python types in the deephaven.dtypes package.

Importing deephaven.dtypes

Deephaven recommends importing this package as follows:

import deephaven.dtypes as dht

Values

The following values can be found in the deephaven.dtypes package:

bool_           # Java boolean
byte # Signed byte
int8 # Signed byte
short # Signed short
int16 # Signed short
char # Character
int32 # Signed 32 bit integer
long # Signed 64 bit integer
int64 # Signed 64 bit integer
int_ # Signed 64 bit integer
float32 # Single precision floating point
single # Single precision floating point
float64 # Double precision floating point
double # Double precision floating point
float_ # Double precision floating point
string # String
BigDecimal # Java BigDecimal
StringSet # Deephaven StringSet
DateTime # Deephaven DateTime
Period # Deephaven time period
PyObject # Python object
JObject # Java object
byte_array # Byte array
int8_array # Byte array
short_array # Short array
int16_array # Short array
int32_array # 32 bit integer array
long_array # 64 bit integer array
int64_array # 64 bit integer array
int_array # 64 bit integer array
single_array # Single precision floating point array
float32_array # Single precision floating point array
double_array # Double precision floating point array
float64_array # Double precision floating point array
float_array # Double precision floating point array
string_array # String array
datetime_array # Deephaven DateTime array

Example usage

One application of Deephaven types is to set the column types for a Dynamic Table Writer. The following example creates 5 different tables, each containing a column for a different type contained within deephaven.dtypes.

from deephaven import DynamicTableWriter
from deephaven import dtypes as dht
from deephaven import time as dhtu

col_defs_1 = \
{\
"Boolean": dht.bool_, "Byte": dht.byte, "Short": dht.short, "Int32": dht.int32, "Int64": dht.long\
}
col_defs_2 = \
{\
"Single": dht.single, "Double": dht.double, "String": dht.string, "BigDecimal": dht.BigDecimal\
}
col_defs_3 = \
{\
"DateTime": dht.DateTime, "Period": dht.Period, "PyObject": dht.PyObject, "JObject": dht.JObject\
}
col_defs_4 = \
{\
"ByteArray": dht.byte_array, "ShortArray": dht.short_array, "IntArray": dht.int32_array, "LongArray": dht.long_array\
}
col_defs_5 = \
{\
"SingleArray": dht.single_array, "DoubleArray": dht.double_array, "StringArray": dht.string_array, "DateTimeArray": dht.datetime_array\
}

dtw1 = DynamicTableWriter(col_defs_1)
t1 = dtw1.table
dtw1.write_row(True, 1, 2, 3, 4)

dtw2 = DynamicTableWriter(col_defs_2)
t2 = dtw2.table
BigDecimal = dht.BigDecimal
dtw2.write_row(3.1, 2.9, "Hello World!", BigDecimal(3.14159))

dtw3 = DynamicTableWriter(col_defs_3)
t3 = dtw3.table
dtw3.write_row(dhtu.now(), dhtu.Period("T1H"), 3, "a")

dtw4 = DynamicTableWriter(col_defs_4)
t4 = dtw4.table
dtw4.write_row(dht.array(dht.byte, [1, 2, 3]), dht.array(dht.short, [1, 2, 3]), dht.array(dht.int32, [1, 2, 3]), dht.array(dht.long, [1, 2, 3]))

dtw5 = DynamicTableWriter(col_defs_5)
t5 = dtw5.table
dtw5.write_row(dht.array(dht.single, [1.1, 2.2]), dht.array(dht.double, [1.1, 2.2]), dht.array(dht.string, ["a", "b"]), dht.array(dht.DateTime, [dhtu.to_datetime("2021-01-01T00:00:00 NY"), dhtu.to_datetime("2022-01-01T00:00:00 NY")]))