Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functions output is inconsistent (different number of columns) when querying one/multiple sites. #25

Open
cjbas22 opened this issue Oct 3, 2022 · 2 comments

Comments

@cjbas22
Copy link

cjbas22 commented Oct 3, 2022

Issue

The following functions: get_qwdata, get_discharge_measurements, get_discharge_peaks, get_gwlevels, get_stats, get_dv, get_info, get_iv will output a dataframe with a datetime index when a single site is provided and a dataframe with a MultiIndex (site/datetime) when more than 1 site is provided.

To Reproduce

Single site:
site_id = "434400121275801"
nwis.get_gwlevels(sites=site_id)

More than one site:
site_ids = ["434400121275801", "375907091432201"]
nwis.get_gwlevels(sites=site_ids)

Expected behavior
For consistency, both queries should return similar dataframes.

@cjbas22 cjbas22 changed the title Makin Functions output is inconsistent (different number of columns) when querying one/multiple sites. Oct 3, 2022
cjbas22 added a commit that referenced this issue Oct 4, 2022
This modification addresses issue #25  by adding an additional parameter multi_index to some functions. When multi_index=False the output will be a dataframe with a single-level index (datetime) independently of the number of sites being queried.
@sblack-usu
Copy link
Collaborator

There are two more scenarios:

nwis.get_gwlevels(sites=site_id, multi_index=True) # what happens here?  Can a single site produce a multi_index?
nwis.get_gwlevels(sites=site_ids, multi_index=True) # This will produce the previous versions result.

@cjbas22
Copy link
Author

cjbas22 commented Oct 5, 2022

If a single site is provided the output is always a dataframe with a single level (datetime) Index. multi_index doesn't do anythign in this case as format_response checks "if len(df['site_no'].unique()) > 1" first.

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

No branches or pull requests

2 participants