Set date_format to ISO8601 to silence pandas 2.0 UserWarning on read_csv#2569
Merged
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
weiji14
commented
Jun 9, 2023
pygmt/src/x2sys_cross.py
Outdated
| 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", |
Member
Author
There was a problem hiding this comment.
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?
Member
There was a problem hiding this comment.
make things backwards compatible with pandas=1.x?
This would be better.
Member
Author
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.
weiji14
commented
Jun 9, 2023
seisman
approved these changes
Jun 9, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 todateutil. To ensure parsing is consistent and as-expected, please specify a format..Note that this requires
pandas>=2.0to work.References:
Fixes #2480
Reminders
make formatandmake checkto 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