elphick.geomet.utils.pandas.weight_average

elphick.geomet.utils.pandas.weight_average(df, mass_wet=None, mass_dry='mass_dry', moisture_column_name=None, component_columns=None, composition_units='%')[source]

Weight Average a DataFrame containing mass-composition

Parameters:
  • df (DataFrame) – The pd.DataFrame containing mass-composition. H2O if provided will be ignored. All columns other than the mass_wet and mass_dry are assumed to be additive, that is, dry mass weighting is valid. Assumes composition is in %w/w units.

  • mass_wet (Optional[str]) – The optional wet mass column.

  • mass_dry (str) – The dry mass column, not optional. Consider solve_mass_moisture prior to this call if needed.

  • moisture_column_name (Optional[str]) – if mass_wet is provided, the resultant moisture will be returned with this column name. If None, and moisture is detected in the input, that column name will be used instead.

  • component_columns (Optional[list[str]]) – The composition columns to be used for the calculation. If not provided, the columns will be auto-detected using a case in-sensitive match to all elements and oxides. H2O is excluded

  • composition_units (Literal['%', 'ppm', 'ppb']) – determines the factor to convert mass to composition.

Return type:

Series

Returns:

A pd.Series containing the total mass and weight averaged composition.