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

Resolve nwis service raising pandas FutureWarning #210

Conversation

aaraney
Copy link
Member

@aaraney aaraney commented Nov 18, 2022

pandas >= 1.5.0 was raising FutureWarning in nwis_client.get because of ambiguity in setting a column's values in-place or replacing the column's underlying array. Specifically, the warning is:

FutureWarning: In a future version, 
`df.iloc[:, i] = newvals` will attempt to set the values inplace instead of always setting a new array. To 
retain the old behavior, use either `df[df.columns[i]] = newvals` or, if columns are non-unique, 
`df.isetitem(i, newvals)` dfs.loc[:, "value"] = pd.to_numeric(dfs["value"], downcast="float")

This PR fixes that issue.

fixes #209

nwis_client

Changes

Testing

  1. test added to verify warning is not raised in nwis_client.get.

Checklist

  • PR has an informative and human-readable title
  • PR is well outlined and documented. See #12 for an example
  • Changes are limited to a single goal (no scope creep)
  • Code can be automatically merged (no conflicts)
  • Code follows project standards (see CONTRIBUTING.md)
  • Passes all existing automated tests
  • Any change in functionality is tested
  • New functions are documented (with a description, list of inputs, and expected output) using numpy docstring formatting
  • Placeholder code is flagged / future todos are captured in comments
  • Reviewers requested with the Reviewers tool ➡️

@aaraney
Copy link
Member Author

aaraney commented Nov 18, 2022

So, the one of the nwm_client_new's tests are failing.

FAILED python/nwm_client_new/tests/test_NWMFileProcessor.py::test_get_dataset - AttributeError: 'EntryPoints' object has no attribute 'get'

I am going to move this to an new issue, so we can track it there. The "good news" however, is that the nwis_client tests passed.

@jarq6c jarq6c merged commit 6517e72 into NOAA-OWP:main May 19, 2023
@aaraney aaraney deleted the fix-nwis-service-pandas-inplace-future-warning-issue branch May 19, 2023 16:12
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.

NWIS IV Client FutureWarning
2 participants