Row
Entry
dataclass
Bases: Row[S]
A row with shape information, useful for initializing a dataframe with an explicit schema
rather than just representing an existing row. Use Entry.of for constructing DataFrames out of
Python values in a somewhat type-safe manner
Named Entry as it's something you're entering into a dataframe than just retrieving
Source code in typol/row.py
of(*initializers, partial=False)
staticmethod
Construct a row out of type checked Intializers for a shape:
Entry.of( # creates a Entry[Account]
Account.name.set(account_name), # ensures `account_name: str`
Account.code.set(account_code), # ensures `account_code: int`
)
Source code in typol/row.py
partial(*initializers)
classmethod
Construct a row out of type checked Intializers for a shape:
Entry.partial( # creates a Entry[Account]
Account.name.set(account_name), # ensures `account_name: str`
Account.code.set(account_code), # ensures `account_code: int`
)
This allows some columns to be left unset
Source code in typol/row.py
Row
dataclass
Bases: Mapping[str, Any]
Represents a single entry across columns in a DataFrame. Use Entry.of for
constructing Rows in a somewhat type-safe manner
Unlike full Entrys, Rows can be built from a DataFrame with iter_rows() since they don't
require a reified shape; in essence Rows come from DataFrames, whereas Entrys can be put
into DataFrames
Source code in typol/row.py
__getitem__(dim)
Retrieve column from row. This will raise a KeyError if the column is not set (i.e. null)
for this row. To get a None value, use .get(...)
Source code in typol/row.py
__iter__()
__len__()
__post_init__()
Ensure only present columns are set in the mapping
entry(shape)
Create an Entry with reified (run-time) shape information for construction of a dataframe
get(dim, *args, **kwargs)
Retrieve column from row, returning None or default= if the column is unset (i.e. null)
for this row. To avoid handling Nones, use row[Shape.col], although note that will raise
an error if the column is unset