-
Notifications
You must be signed in to change notification settings - Fork 224
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
Set date_format to ISO8601 to silence pandas 2.0 UserWarning on read_csv #2569
Conversation
Use `pd.read_csv(..., date_format="ISO8601")` to silence `UserWarning: Could not infer format, so each element will be parsed individually, falling back to `dateutil`. To ensure parsing is consistent and as-expected, please specify a format.`. Xref pandas-dev/pandas#50601
pygmt/src/x2sys_cross.py
Outdated
@@ -235,6 +235,7 @@ def x2sys_cross(tracks=None, outfile=None, **kwargs): | |||
header=2, # Column names are on 2nd row | |||
comment=">", # Skip the 3rd row with a ">" | |||
parse_dates=[2, 3], # Datetimes on 3rd and 4th column | |||
date_format="ISO8601", |
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.
This date_format
parameter only works with pandas>=2.0
. Do we want to set a minimum version of pandas, or make things backwards compatible with pandas=1.x?
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.
make things backwards compatible with pandas=1.x?
This would be better.
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.
Only use the date_format="ISO8601" argument when pandas>=2.0.0 is used. Set CI Tests Legacy to run with pandas<2 to ensure this works.
Description of proposed changes
Use
pd.read_csv(..., date_format="ISO8601")
to silenceUserWarning: Could not infer format, so each element will be parsed individually, falling back to
dateutil. To ensure parsing is consistent and as-expected, please specify a format.
.Note that this requires
pandas>=2.0
to work.References:
Fixes #2480
Reminders
make format
andmake check
to make sure the code follows the style guide.doc/api/index.rst
.Slash Commands
You can write slash commands (
/command
) in the first line of a comment to performspecific operations. Supported slash commands are:
/format
: automatically format and lint the code/test-gmt-dev
: run full tests on the latest GMT development version