-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Address pandas deprecation warnings #1995
Conversation
looks like ME only exists for pandas 2.2+
Ready for review. The linter is complaining about lines I didn't touch, so I didn't fix them. I'm not sure why codecov is failing. |
@@ -146,7 +146,7 @@ def read_surfrad(filename, map_variables=True): | |||
metadata['surfrad_version'] = int(metadata_list[-1]) | |||
metadata['tz'] = 'UTC' | |||
|
|||
data = pd.read_csv(file_buffer, delim_whitespace=True, | |||
data = pd.read_csv(file_buffer, sep=r'\s+', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The warning states:
"FutureWarning: The 'delim_whitespace' keyword in pd.read_csv is deprecated and will be removed in a future version. Use sep='\s+' instead",
Is there a reason that you're using a single backslash?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sep='\\s+'
is equivalent to sep=r'\s+'
, I just preferred to use an r
string instead of escaping the backslash
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured - thanks for letting me know!
[ ] Closes #xxxx[ ] Updates entries indocs/sphinx/source/reference
for API changes.[ ] Adds description and name entries in the appropriate "what's new" file indocs/sphinx/source/whatsnew
for all changes. Includes link to the GitHub Issue with:issue:`num`
or this Pull Request with:pull:`num`
. Includes contributor name and/or GitHub username (link with:ghuser:`user`
).[ ] New code is fully documented. Includes numpydoc compliant docstrings, examples, and comments where necessary.remote-data
) and Milestone are assigned to the Pull Request and linked Issue.See #1994 (comment).
This PR addresses many pandas deprecation warnings. Most of them are just frequency string replacements like
H -> h
in calls topd.date_range
, but there are some others as well. For future reference, here are the warnings addressed:sep='\\s+'
instead",There are two warnings remaining. The first is:
ME
doesn't exist until pandas 2.2, so we can't use it yet. This is only four warnings intest_clearsky.py
, so we can live with it for now.The second is a warning where we are already doing the right/future-compatible thing, but I don't know how to suppress the warning. I guess we should ignore it until it eventually goes away:
replace
is deprecated and will be removed in a future version. To retain the old behavior, explicitly callresult.infer_objects(copy=False)
. To opt-in to the future behavior, setpd.set_option('future.no_silent_downcasting', True)