elphick.geomet.utils.pandas.mass_to_composition
- elphick.geomet.utils.pandas.mass_to_composition(df, mass_wet='mass_wet', mass_dry='mass_dry', moisture_column_name=None, component_columns=None, composition_units='%')[source]
Convert a mass DataFrame to composition
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 excludedcomposition_units (
Literal
['%'
,'ppm'
,'ppb'
]) – determines the factor to convert mass to composition.
- Return type:
DataFrame
- Returns:
A pd.Dataframe containing mass (wet and dry mass) and composition