From d1ab4e6f6aa2d01bd5092ac5df0a569bc8c60a72 Mon Sep 17 00:00:00 2001 From: qorud02 <74843284+qorud02@users.noreply.github.com> Date: Mon, 5 Oct 2026 01:32:23 +0900 Subject: [PATCH 1/2] Keep selected camel-case OGC properties in normalized results --- dataretrieval/ogc/shaping.py | 11 ++++++++--- tests/waterdata_utils_test.py | 25 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/dataretrieval/ogc/shaping.py b/dataretrieval/ogc/shaping.py index 8e874606..121c4448 100644 --- a/dataretrieval/ogc/shaping.py +++ b/dataretrieval/ogc/shaping.py @@ -230,8 +230,9 @@ def _arrange_cols( df : pd.DataFrame The input DataFrame whose columns are to be rearranged or renamed. properties : Optional[List[str]] - A list of column names to possibly rename. If None or contains - only NaN, the function renames 'id' to output_id. + Requested column names. Camel-case names are matched to normalized + snake_case DataFrame columns. If None or contains only NaN, the + function renames 'id' to output_id. output_id : str The name to which the 'id' column should be renamed if applicable. extra_id_cols : set or frozenset, optional @@ -261,7 +262,11 @@ def _arrange_cols( # --- Explicit properties: select and reorder columns per the list --- # Do not alias the caller's list; it is mutated below. - local_properties = list(properties) + # Match the names normalized by _finalize_ogc before selecting columns. + local_properties = [ + _to_snake_case(name) if isinstance(name, str) else name + for name in properties + ] if "geometry" in df.columns and "geometry" not in local_properties: local_properties.append("geometry") # 'id' is a valid collection column, but expose it under the diff --git a/tests/waterdata_utils_test.py b/tests/waterdata_utils_test.py index aa07ec29..79290df5 100644 --- a/tests/waterdata_utils_test.py +++ b/tests/waterdata_utils_test.py @@ -239,6 +239,31 @@ def test_finalize_ogc_truncates_combined_to_max_rows(): assert hasattr(md, "url") # wrapped as BaseMetadata +def test_finalize_ogc_keeps_requested_camel_case_property(): + """A selected API property remains in the normalized result frame.""" + frame = pd.DataFrame( + {"id": ["obs-1"], "sampleTime": ["2024-01-01T00:00:00Z"], "value": [1.0]} + ) + response = mock.MagicMock() + response.url = "https://example.com/collections/things/items" + response.elapsed = datetime.timedelta(seconds=0.1) + response.headers = {} + properties = ["sampleTime"] + + result, _ = _finalize_ogc( + frame, + response, + properties=properties, + output_id="thing_id", + convert_type=False, + collection="things", + ) + + assert result.columns.tolist() == ["sample_time"] + assert result["sample_time"].tolist() == ["2024-01-01T00:00:00Z"] + assert properties == ["sampleTime"] + + def _resp_ok(features): """Build a 200-OK mock response with the given features list.""" links = [{"rel": "next", "href": "https://example.com/page2"}] if features else [] From a589b82e3a21d97048b77c1841d1638e4507db59 Mon Sep 17 00:00:00 2001 From: Kyunghan Bae <74843284+qorud02@users.noreply.github.com> Date: Mon, 5 Oct 2026 23:59:11 +0900 Subject: [PATCH 2/2] Apply Ruff formatting to requested OGC properties --- dataretrieval/ogc/shaping.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dataretrieval/ogc/shaping.py b/dataretrieval/ogc/shaping.py index 121c4448..4659080e 100644 --- a/dataretrieval/ogc/shaping.py +++ b/dataretrieval/ogc/shaping.py @@ -264,8 +264,7 @@ def _arrange_cols( # Do not alias the caller's list; it is mutated below. # Match the names normalized by _finalize_ogc before selecting columns. local_properties = [ - _to_snake_case(name) if isinstance(name, str) else name - for name in properties + _to_snake_case(name) if isinstance(name, str) else name for name in properties ] if "geometry" in df.columns and "geometry" not in local_properties: local_properties.append("geometry")