Chalk DataFrames
Inspect column names and types, and set a column's type when you construct a DataFrame.
A DataFrame’s schema gives the name and type of each column. When you construct a frame from a dictionary, each key names a column and ChalkDF infers its type from the values. To set a column’s type explicitly, supply a typed Arrow array for that column.
import pyarrow as pa
from chalkdf import DataFrame
orders = DataFrame({
"id": ["001", "002"],
"amount": pa.array([8, 30], type=pa.int32()),
})
orders| # | idstring | amountint32 |
|---|---|---|
| 1 | 001 | 8 |
| 2 | 002 | 30 |
The string IDs retain their leading zeros. A Python list of these amounts would produce an int64 column. The typed array gives amount the narrower int32 type. Inspect an individual column’s type with orders.schema["amount"].
To specify types for an entire table, see Python and Arrow. To build a query before its rows arrive, see Named table inputs.