elphick.geomet.utils.pandas.composition_to_mass

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

Convert a composition DataFrame to mass

Supplementary columns (columns that are not mass or composition) are ignored.

Parameters:
  • df (DataFrame) – The pd.DataFrame containing mass. 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 wet mass column, optional. If not provided, it’s assumed to be equal to mass_dry.

  • 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 composition to mass.

  • return_moisture (bool) – If True, the moisture column will be returned.

Return type:

DataFrame

Returns:

A pd.Dataframe containing the mass representation of mass totals and components