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:
dht.bool_
dht.byte
dht.short
dht.int16
dht.char
dht.int_
dht.int32
dht.long_
dht.int64
dht.float_
dht.single
dht.float32
dht.double
dht.float64
dht.string
dht.bigdecimal
dht.stringset
dht.datetime
dht.timeperiod
dht.byte_array
dht.short_array
dht.int16_array
dht.int_array
dht.int32_array
dht.long_array
dht.int64_array
dht.float_array
dht.single_array
dht.float32_array
dht.double_array
dht.float64_array
dht.string_array
Example usage
One application of Deephaven types is to set the column types for a Dynamic Table Writer. The following example sets the "Key" column as a String, and the "Value" column as an integer in the dynamic table.
from deephaven import DynamicTableWriter
import deephaven.dtypes as dht
import threading
import time
dynamic_table_writer_columns = {
"Key": dht.string,
"Value": dht.int_
}
table_writer = DynamicTableWriter(dynamic_table_writer_columns)
table = table_writer.table
def thread_func():
for i in range(10):
table_writer.write_row(str(i), i)
time.sleep(2)
thread = threading.Thread(target=thread_func)
thread.start()
- table