to_habitat_feature_panel

Note

This page is a reference documentation. It only explains the function signature, and not how to use it. Please refer to the Habitat Guide and Python API guide (v2.0) for usage.

to_habitat_feature_panel(data: HabitatFeaturePanel | FeatureTable | DataFrame, *, subject_column: str | None = None, habitat_column: str = 'habitat', feature_column: str = 'feature', value_column: str = 'value') → HabitatFeaturePanel[source]

Melt a wide each_habitat table, or wrap an already-long frame.

Wide columns must match habitat_{id}_{feature} (the EachHabitatRadiomicsFeatures layout). Presence flags has_habitat_{id} are ignored. Rows whose value is NaN are dropped – that is the honest “habitat absent / not measured” state, not a zero.

A DataFrame that already has habitat / feature / value columns is used as-is (plus a subject column).

Parameters:
  • data – FeatureTable, a wide or long DataFrame, or an existing panel.

  • subject_column – Subject id column. Defaults to the table’s first id column, or subject.

  • habitat_column – Habitat id column name in a long frame, and in the returned panel.

  • feature_column – Feature-name column in a long frame.

  • value_column – Numeric column in a long frame.

Returns:

A long HabitatFeaturePanel.

Raises:

HABITAPIError – If no habitat feature columns can be found.