Skip to content

fix: preserve leading zeros in HUC codes by casting to str - #42

Open
Ehakl wants to merge 1 commit into
Dewberry:mainfrom
Ehakl:fix/huc-leading-zeros
Open

fix: preserve leading zeros in HUC codes by casting to str#42
Ehakl wants to merge 1 commit into
Dewberry:mainfrom
Ehakl:fix/huc-leading-zeros

Conversation

@Ehakl

@Ehakl Ehakl commented Sep 8, 2026

Copy link
Copy Markdown

Fixes #40

Problem

The huc_cd value returned by load_site_data() in data_retrieval.py was not explicitly cast to a string. When the NWIS API returns HUC codes with leading zeros (e.g. 01080106 for site 01151500), pandas can silently cast the value to an integer, dropping the leading zero and producing 1080106.

Fix

Wrap resp['huc_cd'].iloc[0] in str() on line 301 of hydroshift/utils/data_retrieval.py to ensure the HUC code is always stored as a string, preserving any leading zeros.

This is a one-line change with no side effects — the value is only ever used for display in the site_summary.md template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HUC code is cast to int, so leading 0s are dropped

1 participant