From 8a64e686215c14dc1d795db2ed46720629a98993 Mon Sep 17 00:00:00 2001 From: David Huard Date: Tue, 10 Feb 2026 15:41:42 -0500 Subject: [PATCH 1/2] save _start_date and _end_date when parsing netcdf file --- pyproject.toml | 2 +- src/ravenpy/config/utils.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a16047b5..9268d9bc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,7 +47,7 @@ dependencies = [ "matplotlib >=3.6.0", "numpy >=1.25.0", "owslib >=0.29.1", - "pandas >=2.2.0,<3.0", + "pandas >=2.2.0", "pint >=0.24.4", "pydantic >=2.11", "pydap >=3.5.6", diff --git a/src/ravenpy/config/utils.py b/src/ravenpy/config/utils.py index acfb1c28..ae84cf04 100644 --- a/src/ravenpy/config/utils.py +++ b/src/ravenpy/config/utils.py @@ -1,5 +1,7 @@ +import datetime as dt import os import typing +import warnings from collections.abc import Sequence from pathlib import Path from typing import Optional, Union @@ -126,6 +128,13 @@ def nc_specs( if ds["station_id"].shape and len(ds["station_id"]) > i: attrs["name"] = ds["station_id"].values[i] + # Extract start and end datetime as private attributes + try: + attrs["_start_date"] = np.datetime64(ds.cf["time"][0].values, "us").astype(dt.datetime) + attrs["_end_date"] = np.datetime64(ds.cf["time"][-1].values, "us").astype(dt.datetime) + except: + warnings.info("Could not extract start and end dates from dataset.") + return attrs From d61006bca683f96ce13e777343a778ed70fd7f04 Mon Sep 17 00:00:00 2001 From: David Huard Date: Tue, 10 Feb 2026 16:13:12 -0500 Subject: [PATCH 2/2] fix groupby deprecation --- src/ravenpy/extractors/routing_product.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/ravenpy/extractors/routing_product.py b/src/ravenpy/extractors/routing_product.py index 9381c5da..1da02e39 100644 --- a/src/ravenpy/extractors/routing_product.py +++ b/src/ravenpy/extractors/routing_product.py @@ -405,7 +405,7 @@ def extract(self) -> dict: # Read routing data # WGS 84 / North Pole LAEA Canada - self._routing_data = self._routing_data.to_crs(epsg=GridWeightExtractor.CRS_CAEA) + df = self._routing_data.to_crs(epsg=GridWeightExtractor.CRS_CAEA) def keep_only_valid_downsubid_and_obs_nm(g): """ @@ -436,13 +436,7 @@ def keep_only_valid_downsubid_and_obs_nm(g): return row # Remove duplicate HRU_IDs while making sure that we keep relevant DowSubId and Obs_NM values - # FIXME: DeprecationWarning: DataFrameGroupBy.apply operated on the grouping columns. - # This behavior is deprecated, and in a future version of pandas the grouping columns will be - # excluded from the operation. Either pass `include_groups=False` to exclude the groupings or - # explicitly select the grouping columns after groupby to silence this warning. - self._routing_data = self._routing_data.groupby(self._routing_id_field, group_keys=False).apply( - keep_only_valid_downsubid_and_obs_nm, include_groups=True - ) + self._routing_data = df.groupby(self._routing_id_field, group_keys=False)[df.columns.to_list()].apply(keep_only_valid_downsubid_and_obs_nm) # Make sure those are ints self._routing_data.SubId = self._routing_data.SubId.astype(int)