Skip to content

Commit

Permalink
Update date parsing for river data collection
Browse files Browse the repository at this point in the history
Changed the date_parser to date_format in collect_river_data.py to use ISO8601
date format. Updated corresponding unit test mock in test_collect_river_data.py
for consistency. These changes were required due to deprecation of date_parser
in pandas=2.0.0.

re: issue #290
  • Loading branch information
douglatornell committed Sep 1, 2024
1 parent 0810d54 commit 19bd0ba
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion nowcast/workers/collect_river_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def _calc_eccc_day_avg_discharge(river_name, data_date, config):
csv_file,
usecols=["Date", "Discharge / Débit (cms)"],
index_col="Date",
date_parser=lambda x: pandas.to_datetime(x.rpartition("-")[0]),
date_format="ISO8601",
)
day_avg_discharge = df.loc[f"{data_date.format('YYYY-MM-DD')}"].mean()[
"Discharge / Débit (cms)"
Expand Down
2 changes: 1 addition & 1 deletion tests/workers/test_collect_river_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ class TestCalcECCC_DayAvgDischarge:
"""Unit test for _calc_eccc_day_avg_discharge() function."""

def test_calc_eccc_day_avg_discharge(self, config, caplog, tmp_path, monkeypatch):
def mock_read_csv(csv_file, usecols, index_col, date_parser):
def mock_read_csv(csv_file, usecols, index_col, date_format):
return pandas.DataFrame(
numpy.linspace(41.9, 44.1, 290),
index=pandas.date_range(
Expand Down

0 comments on commit 19bd0ba

Please sign in to comment.