Column Names get Mangled for Dam Headwater / Tailwater Stage Observations

Open
#177 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
api, data

Research direction

Start by running the get_record() example from the issue for the two listed site numbers and parameter 00065, then trace how observation column names are built. The fix is done when headwater and tailwater columns have consistent, usable names without stray brackets or quote characters, and the reported CSV headers remain correct.

Written by the indexing model from the issue text.

Description

The column names assigned to the output of get_record() come out with a mess of quotes and brackets, for dam headwater and tailwater stage observations.

sns = [
'03612600', # Ohio River at Olmsted Dam
'03399800', # Ohio River at Smithland Dam
]
start_date = '2014-10-01'
end_date = '2023-09-30'
param_code = '00065'

for sn in sns:
df = nwis.get_record(sn, start_date, end_date, parameterCd=param_code)
print(df.columns)

Index(['site_no', '00065_headwater, [headwater',
'00065_headwater, [headwater_cd', '00065_tailwater',
'00065_tailwater_cd'],
dtype='object')
Index(['site_no', '00065_headwater', '00065_headwater_cd',
'00065_stage - tailwater, [tailwater',
'00065_stage - tailwater, [tailwater_cd'],
dtype='object')

When written to a csv:
datetime,site_no,00065_headwater,00065_headwater_cd,"00065_stage - tailwater, [tailwater","00065_stage - tailwater, [tailwater_cd"
2014-10-01 05:00:00+00:00,03399800,13.66,A,12.12,A
2014-10-01 05:15:00+00:00,03399800,13.66,A,12.07,A
2014-10-01 05:30:00+00:00,03399800,13.66,A,12.11,A
2014-10-01 05:45:00+00:00,03399800,13.66,A,12.15,A

Dominant language
Python
Stars
266
Forks
63
Avg merge
1d 20h
Merged PRs (30d)
19

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from DOI-USGS/dataretrieval-python

All issues in DOI-USGS/dataretrieval-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.