-
Notifications
You must be signed in to change notification settings - Fork 3.7k
GH-34283 [Python] Add types_mapper support to index for to_pandas #34445
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
Conversation
|
|
1 similar comment
|
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.
Thank you for another fix @phofl! 🤩
The solution is much nicer than I thought it would be. And I only have one small nit question in the tests.
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.
Looks good!
python/pyarrow/tests/test_pandas.py
Outdated
@@ -647,6 +647,23 @@ def test_mismatch_metadata_schema(self): | |||
result = new_table.to_pandas() | |||
tm.assert_frame_equal(result, expected) | |||
|
|||
@pytest.mark.parametrize("index", ["a", ["a", "b"]]) | |||
def test_to_pandas_types_mapper_index(self, index): |
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 other types_mapper related tests are lower in the file (not in one of the classes), so I would move it there (eg just below test_roundtrip_empty_table_with_extension_dtype_index
)
(Sidenote, seeing that test_roundtrip_empty_table_with_extension_dtype_index
test, that seems to be something that should be fixed as well, preserving interval index)
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.
Moved
Thanks @phofl ! |
Benchmark runs are scheduled for baseline = 17f416f and contender = b679a96. b679a96 is a master commit associated with this PR. Results will be available as each benchmark for each run completes. |
Rationale for this change
What changes are included in this PR?
Only respects types_mapper for indexes as well
Are these changes tested?
Yes
Are there any user-facing changes?
Technically this breaks the API in a way that we would now respect the types_mapper for the index.
Table.to_pandas
fails to convert indexdtype
with a custom type mapper #34283cc @jorisvandenbossche