ds_provider_unimicro_py_lib.utils.dataframe

File: dataframe.py Region: ds_provider_unimicro_py_lib/utils/dataframe

Helpers for shaping dataset output frames.

Functions

project_fields(→ pandas.DataFrame)

Restrict the output to fields (ignoring names that are not present), if configured.

Module Contents

ds_provider_unimicro_py_lib.utils.dataframe.project_fields(output: pandas.DataFrame, fields: list[str] | None) → pandas.DataFrame[source]

Restrict the output to fields (ignoring names that are not present), if configured.

Parameters:
  • output – The normalized output dataframe.

  • fields – Column names to keep, in the requested order. None or empty keeps everything.

Returns:

The projected dataframe, or the input unchanged when fields is not set. If none of the requested fields exist, an empty frame with the same index is returned.

Return type:

pd.DataFrame