biopsykit.metadata package

Module with functions to compute metadata information.

biopsykit.metadata.bmi(data, columns=None)[source]

Compute the Body Mass Index.

This function assumes the required data in the following format:

  • 1st column: weight in kilogram

  • 2nd column: height in centimeter

If data is a dataframe that contains more than the required two columns, e.g., if the complete questionnaire dataframe is passed, the required columns can be sliced by specifying them in the columns parameter.

Parameters
  • data (DataFrame) – dataframe containing weight and height information

  • columns (sequence of str, optional) – list of column names needed to compute body mass index. Only needed if data is a dataframe with more than the required columns for computing body mass index. Not needed if data only contains the required columns. Default: None

Returns

dataframe with body mass index

Return type

DataFrame

Raises

ValueRangeError – if input values or output values are not in the expected range, e.g., because values are provided in the wrong unit or columns are in the wrong order

biopsykit.metadata.whr(data, columns=None)[source]

Compute the Waist to Hip Ratio.

This function assumes the required data in the following format:

  • 1st column: waist circumference

  • 2nd column: hip circumference

If data is a dataframe that contains more than the required two columns, e.g., if the complete questionnaire dataframe is passed, the required columns can be sliced by specifying them in the columns parameter.

Parameters
  • data (DataFrame) – dataframe containing waist and hip circumference

  • columns (sequence of str, optional) – list of column names needed to compute body mass index. Only needed if data is a dataframe with more than the required columns for computing body mass index. Not needed if data only contains the required columns. Default: None

Returns

dataframe with waist to hip ratio

Return type

DataFrame

Raises

ValueRangeError – if input values or output values are not in the expected range, e.g., because values are provided in the wrong unit or column are in the wrong order

biopsykit.metadata.gender_counts(data, gender_col=None, split_condition=False)[source]

Get statistics about gender distribution from a dataset.

Parameters
  • data (DataFrame) – dataframe with subjects

  • gender_col (str, optional) – column name containing gender information or None to use default name (“gender”).

  • split_condition (bool, optional) – True to split gender distribution by condition (assumes that an “condition” index level is present in data), False otherwise. Default: False

Returns

dataframe with absolute and relative gender distribution

Return type

DataFrame