to_pandas
The to_pandas method converts a Deephaven table to a pandas.DataFrame.
Caution
to_pandas clones an entire table into memory. For large tables, consider limiting the number of rows and columns in the table before using this method.
Syntax
to_pandas(
table: Table,
cols: list[str] = None,
dtype_backend: str = 'numpy_nullable',
conv_null: bool = True
) -> pandas.DataFrame
Parameters
| Parameter | Type | Description |
|---|---|---|
| table | Table | The source table to convert. |
| cols optional | list[str] | The source table columns to convert. If not specified, all columns are converted. |
| dtype_backend optional | str | Which
Both “numpy_nullable” and “pyarrow” automatically convert Deephaven nulls to pandas NA and enable pandas extension types. Extension types are needed to support types beyond NumPy’s type system. Extension types support operations such as properly mapping Java Strings to Python strings. |
| conv_null optional | bool | When |
Returns
A pandas.DataFrame.
Example
The following example uses new_table to create a table, then converts it to a pandas.DataFrame with to_pandas.
from deephaven.pandas import to_pandas
from deephaven import new_table
from deephaven.column import int_col
source = new_table([int_col("Num1", [1, 2, 3, 4]), int_col("Num2", [5, 6, 7, 8])])
result = to_pandas(source)