From d2c68b2aa4fa9abe5466293a569760142e4aa663 Mon Sep 17 00:00:00 2001 From: Bousquin Date: Tue, 12 Sep 2023 20:09:55 -0500 Subject: [PATCH] Added examples to docs --- harmonize_wq/harmonize.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/harmonize_wq/harmonize.py b/harmonize_wq/harmonize.py index 5632bca..9fd835d 100644 --- a/harmonize_wq/harmonize.py +++ b/harmonize_wq/harmonize.py @@ -545,6 +545,28 @@ def dimensions_list(self, m_mask=None): list List of units with mis-matched dimensions. + Examples + -------- + Build DataFrame to use as input: + + >>> import pandas + >>> df = pandas.DataFrame({'CharacteristicName': ['Phosphorus', + ... 'Phosphorus',], + ... 'ResultMeasure/MeasureUnitCode': ['mg/l', + ... 'mg/kg',], + ... 'ResultMeasureValue': ['1.0', '10',], + ... }) + >>> df + CharacteristicName ResultMeasure/MeasureUnitCode ResultMeasureValue + 0 Phosphorus mg/l 1.0 + 1 Phosphorus mg/kg 10 + + Build WQ Characteristic Data object from DataFrame: + + >>> wq = harmonize.WQCharData(df, 'Phosphorus') + + >>> wq.dimensions_list() + 'mg/kg' """ if m_mask is None: m_mask = self.measure_mask() @@ -562,6 +584,22 @@ def replace_unit_by_str(self, old, new): sub-string to find and replace new : str sub-string to replace old sub-string + + Examples + -------- + Build DataFrame to use as input: + + >>> import pandas + >>> df = pandas.DataFrame({'CharacteristicName': ['Phosphorus', + ... 'Phosphorus',], + ... 'ResultMeasure/MeasureUnitCode': ['mg/l', + ... 'mg/kg',], + ... 'ResultMeasureValue': ['1.0', '10',], + ... }) + >>> df + CharacteristicName ResultMeasure/MeasureUnitCode ResultMeasureValue + 0 Phosphorus mg/l 1.0 + 1 Phosphorus mg/kg 10 """ df_out = self.df c_mask = self.c_mask