Skip to main content
Version: Python

to_table

The to_table method creates a new table from a pandas.DataFrame.

Syntax

to_table(df: pandas.DataFrame, cols: list[str] = None) -> Table

Parameters

ParameterTypeDescription
dfpandas.DataFrame

The pandas.DataFrame instance.

cols optionallist[str]

The columns to convert. If not specified, all columns are converted.

Returns

A Deephaven Table.

Example

The following example uses pandas to create a DataFrame, then converts it to a Deephaven Table with to_table.

from deephaven.pandas import to_table
import pandas as pd

d = {"col1": [1, 2], "col2": [3, 4]}
df = pd.DataFrame(data=d)

result = to_table(df)