phenotypic.util.split_measurements_by_category#

phenotypic.util.split_measurements_by_category(df: DataFrame | DataFrame) → dict[str, DataFrame | DataFrame][source]#

Split a measurements table into one data frame per measurement category.

Context columns are the same as split_measurements(): every column not owned by a producer’s MeasurementInfo (metadata, object label, grid, joined external metadata). Each category frame holds those context columns followed by the present columns whose member carries the category (see phenotypic.schema.CATEGORIES), in input order. Measurement columns outside a category are dropped from its frame. A column in several categories appears in each.

Parameters:

df (DataFrame | DataFrame) – A pandas or polars measurements DataFrame.

Returns:

Mapping of category label (e.g. "StartingMetrics") to a same-type DataFrame. Categories with no present columns are omitted.

Raises:

TypeError – If df is not a pandas or polars DataFrame.

Return type:

dict[str, DataFrame | DataFrame]