FrozenFrame¶
freezeframe.frame.FrozenFrame
¶
Immutable, schema-typed DataFrame backed by a pyarrow.RecordBatch.
Subclass and annotate with native Python types to declare a schema::
class UserMetrics(FrozenFrame):
user_id: int
name: str
score: float
active: bool | None
See the module docstring for construction and usage examples.
Construct directly from a pa.RecordBatch.
Prefer from_dict or from_arrow for everyday use — they
provide clearer error messages when data doesn't match the schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
RecordBatch
|
The Arrow RecordBatch to wrap. |
required |
validate
|
bool
|
When |
True
|
Source code in src\freezeframe\frame.py
__getattr__
¶
Attribute-style column access: df.score.
Only called when normal attribute lookup fails, so internal
attributes (_batch, __schema__, …) are unaffected.
Source code in src\freezeframe\frame.py
__getitem__
¶
Return the column key as a FrozenSeries.
Source code in src\freezeframe\frame.py
__hash__
¶
Stable hash based on the Arrow IPC serialisation of the batch.
Computed once on first call and cached internally.
Source code in src\freezeframe\frame.py
__iter__
¶
Iterate row-wise, yielding each row as a plain Python dict.
Source code in src\freezeframe\frame.py
__len__
¶
from_arrow
classmethod
¶
Construct from an existing pa.RecordBatch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
RecordBatch
|
An Arrow RecordBatch whose schema must match the declared schema. |
required |
validate
|
bool
|
Run schema validation. Defaults to |
True
|
Returns:
| Type | Description |
|---|---|
Self
|
A new instance of the concrete subclass. |
Raises:
| Type | Description |
|---|---|
SchemaValidationError
|
If the batch does not conform to the declared schema. |
Source code in src\freezeframe\frame.py
from_dict
classmethod
¶
Construct from a column-oriented dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Any]
|
Mapping of column name to a sequence of values (list, numpy
array, or any iterable accepted by |
required |
validate
|
bool
|
Run schema validation after building the batch. Defaults to
|
True
|
Returns:
| Type | Description |
|---|---|
Self
|
A new instance of the concrete subclass. |
Raises:
| Type | Description |
|---|---|
SchemaValidationError
|
If the data has unexpected or missing columns, type mismatches, or null values in a non-nullable column. |