How do I get data out of a Deephaven table?
Python
Extracting data from tables is typically done via the deephaven.numpy or deephaven.pandas modules.
Here's an example:
from deephaven.numpy import to_numpy
from deephaven.pandas import to_pandas
from deephaven import empty_table
table = empty_table(10).update(["X=ii", "Y=sqrt(X)"])
table_column_x_np = to_numpy(table, cols=["X"]).flatten()
print(table_column_x_np)
table_column_x_pd = to_pandas(table, cols=["X"])
print(table_column_x_pd)
- Log
Groovy
Extracting data from tables in Deephaven's Groovy API is typically done via the table.getColumnSource
and table.columnIterator
methods.
See our full guide for extracting data from tables in the Groovy API here.
Here's an example:
result = newTable(
intCol("Integers", 1, 2, 3, 4, 5)
)
columnSource = result.getColumnSource("Integers")
// get the ColumnSource
println columnSource
// use the ColumnSource's 'get' method to get the value at a specific index
println columnSource.get(2)
// use columnIterator to iterate over the whole column
iterator = result.columnIterator("Integers")
while (iterator.hasNext()) {
println iterator.next()
}
- Log
note
These FAQ pages contain answers to questions about Deephaven Community Core that our users have asked in our Community Slack. If you have a question that is not in our documentation, join our Community and we'll be happy to help!