typespecs.frame module#
- typespecs.frame.collapse(frame: DataFrame, conflict: Mapping[str, Literal['override', 'update'] | Callable[[Any, Any], Any]] | Literal['override', 'update'] | Callable[[Any, Any], Any] = 'override', /) DataFrame[source]#
Collapse given DataFrame by resolving conflicts between rows.
- Parameters:
frame – DataFrame to collapse.
conflict – Resolution strategy for conflicts between rows. Either a single resolution or a mapping of column names to resolutions is accepted. As built-in resolutions,
"override"(new value overrides old value; default behavior) and"update"(new mapping updates old mapping) are supported. A function that takes old and new values and returns resolved value can also be accepted as a custom resolution.
- Returns:
Collapsed DataFrame.
- typespecs.frame.concat(frames: Iterable[DataFrame], /) DataFrame[source]#
Concatenate DataFrames row-wise with missing values filled with
<NA>.- Parameters:
frames – DataFrames to concatenate.
- Returns:
Concatenated DataFrame.
- typespecs.frame.fillna(frame: DataFrame, value: Mapping[str, ~typing.Any] | ~typing.Any=<NA>, /) DataFrame[source]#
Fill pandas
<NA>in given DataFrame with given value.- Parameters:
frame – DataFrame to fill.
value – Default value for each column. Either a single value or a mapping of column names to values is accepted. If the specified columns are not present in
frame, each column filled with the specified value will be added.
- Returns:
Filled DataFrame.
- typespecs.frame.isna(frame: DataFrame, /) DataFrame[source]#
Detect missing values (
<NA>only) in given DataFrame.- Parameters:
frame – DataFrame to check.
- Returns:
Boolean DataFrame indicating missing values (
<NA>only).
- typespecs.frame.no_silent_downcasting() AbstractContextManager[None][source]#
Context manager to avoid silent downcasting for pandas < 3.
- typespecs.frame.replace(frame: DataFrame, old: Any, new: Any, /, on: Any | None = None) DataFrame[source]#
Replace old value with new value in given DataFrame.
- Parameters:
frame – DataFrame to replace.
old – Old value to replace.
new – New value to replace with.
on – Optional data type to restrict replacement on.
- Returns:
Replaced DataFrame.