NOAA-OWP / hydrotools

Suite of tools for retrieving USGS NWIS observations and evaluating National Water Model (NWM) data.
Other
53 stars 12 forks source link

Resolve nwis service raising pandas FutureWarning #210

Closed aaraney closed 1 year ago

aaraney commented 1 year ago

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

aaraney commented 1 year ago

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.