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.
Note
For pandas < 3, the dtypes of the concatenated DataFrame are always
objectto avoid silent downcasting.
- typespecs.frame.fillna(frame: DataFrame, value: Mapping[str, ~typing.Any] | ~typing.Any=<NA>, /) DataFrame[source]#
Fill missing values (
<NA>only) 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:
DataFrame with missing values (
<NA>only) filled.