pyarrow: Support date32[day] and date64[ms] dtypes in pandas objects#2845
Merged
pyarrow: Support date32[day] and date64[ms] dtypes in pandas objects#2845
Conversation
Handle date columns in pandas.DataFrame with pyarrow dtypes like date32[day][pyarrow] or date64[ms][pyarrow] by modifying the vectors_to_arrays conversion function. Added some parametrized unit tests to test_info.py to ensure this works.
Need to handle Python lists that don't have the dtype attribute, unlike pandas.Series objects. Also ensure that we return a C-contiguous array.
Ensure that pyarrow date32 and date64 dtypes are converted to numpy.datetime64 dtype. Added pyarrow dependency to ci_doctests.yaml. Also changed from using `"date" in vec_dtype` to `vec_dtype.startswith("date")`.
seisman
reviewed
Dec 17, 2023
Co-Authored-By: Dongdong Tian <seisman.info@gmail.com>
seisman
approved these changes
Dec 17, 2023
Member
seisman
left a comment
There was a problem hiding this comment.
Looks good to me, but need to mark the PR as ready for review and merge the main branch to make sure all tests pass.
Member
Author
|
I'm still debating on whether to add pyarrow into pygmt/pygmt/tests/test_plot.py Lines 409 to 452 in 20054a1 That test is already a bit long though ... |
Member
Author
On second thought, I might do this in a follow-up PR. PyArrow also has time32/time64 types, so I might add a |
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
Handle date columns in pandas.DataFrame with pyarrow dtypes like
date32[day][pyarrow]ordate64[ms][pyarrow].This is implemented by modifying the
vectors_to_arraysconversion function to convert date32/date64 dtypes to numpy.datetime64.An altenative implementation would be to handle pyarrow date32/date64 dtypes natively without converting, but this might require more work and discussion at #2800.
Note:
References:
Part of #2800, related to #242, extends #464
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