Implementation:Eventual Inc Daft DataFrame To Pandas
| Knowledge Sources | |
|---|---|
| Domains | Data_Engineering, Interoperability |
| Last Updated | 2026-02-08 00:00 GMT |
Overview
Concrete tool for converting a Daft DataFrame to a pandas DataFrame provided by the Daft library. This is a wrapper doc type for the pandas interoperability method.
Description
The to_pandas method on DataFrame converts the current Daft DataFrame to a pandas DataFrame. It first calls collect() to materialize results if they have not been computed yet, then delegates to the internal result's to_pandas method with the DataFrame's schema and the temporal coercion flag. This is a blocking call that triggers execution of the lazy query plan.
Usage
Call df.to_pandas() on a DataFrame instance. Requires the pandas package to be installed. Use when you need pandas-compatible output.
Code Reference
Source Location
- Repository: Daft
- File:
daft/dataframe/dataframe.py - Lines: L4403-4435
Signature
def to_pandas(self, coerce_temporal_nanoseconds: bool = False) -> pandas.DataFrame
Import
# Method on DataFrame, no separate import needed
# Requires: pandas
pdf = df.to_pandas()
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| coerce_temporal_nanoseconds | bool | No | Whether to coerce temporal columns to nanoseconds. Only applicable to pandas >= 2.0 and pyarrow >= 13.0.0. Defaults to False. |
Outputs
| Name | Type | Description |
|---|---|---|
| return | pandas.DataFrame | A pandas DataFrame containing the materialized data from the Daft DataFrame. |
External Dependencies
- pandas - required for output type
Usage Examples
Basic Usage
import daft
df = daft.from_pydict({"a": [1, 2, 3], "b": [4, 5, 6]})
pd_df = df.to_pandas()
print(pd_df)
# a b
# 0 1 4
# 1 2 5
# 2 3 6
With Temporal Coercion
import daft
df = daft.from_pydict({"ts": [1000000, 2000000, 3000000]})
df = df.with_column("ts", df["ts"].cast(daft.DataType.timestamp("us")))
pd_df = df.to_pandas(coerce_temporal_nanoseconds=True)