Skip to content

Commit

Permalink
Added examples to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jbousquin committed Sep 13, 2023
1 parent fd6fac3 commit d2c68b2
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions harmonize_wq/harmonize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand Down

0 comments on commit d2c68b2

Please sign in to comment.