Chalk DataFrames
Construct a DataFrame from Python values or an Arrow table.
For a small Python dataset, pass a dictionary of equally long columns to DataFrame. When another library already supplies an Arrow table, pass it to from_arrow. Specify Arrow types when values alone cannot establish the intended schema.
import pyarrow as pa
from chalkdf import DataFrame
schema = pa.schema([("id", pa.string()), ("score", pa.float64())])
table = pa.table({"id": ["001", "002"], "score": [None, None]}, schema=schema)
DataFrame.from_arrow(table).to_arrow()| # | idstring | scoredouble |
|---|---|---|
| 1 | 001 | null |
| 2 | 002 | null |
Both scores are missing. The schema still gives score a floating-point type. The final call returns a PyArrow table that you can pass to another Arrow consumer.
See DataFrame.from_dict, DataFrame.from_arrow, DataFrame.to_arrow.