-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
GH-43112: [Python] Set nullable Int64
dtype
for integer columns with None
values when converting to pandas
#44538
Open
attwelveDev
wants to merge
22
commits into
apache:main
Choose a base branch
from
attwelveDev:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+55
−16
Conversation
This file contains 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
Everything looks good. Why is the CI failing? |
I'm not actually sure. It appears |
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.
Rationale for this change
When calling
to_pandas
method on aTable
object, integer columns with at least oneNone
value are converted tofloat64
in the resultant pandasDataFrame
. For example, using thefrom_pydict
method to return aTable
from a PythonDictionary
, say,{“col_name”: [1, None]}
, theto_pandas
method returns aDataFrame
where thedtype
of“col_name”
isfloat64
, and whose values are[1.0, NaN]
. This may cause precision issues when certain integers cannot be precisely converted to a float.What changes are included in this PR?
In the
table_to_dataframe
method, columns with theint64
dtype
and have at least oneNone
value now have theInt64
dtype
inext_columns_dtypes
.Various existing tests were modified to reflect this new behaviour.
Looking to close #43112.
Are these changes tested?
Tests have been added as part of
test_pandas_dtype_conversions
in/python/pyarrow/tests/test_pandas.py
.Are there any user-facing changes?
This may affect instances where integer columns with
None
values are expected to be converted tofloat64
.Additional Notes
There are failing CI tests for other languages, possibly due to unrelated issues from the upstream main branch. All CI tests for Python have been verified to pass.
This is my first contribution to an open source project, and I appreciate any feedback.
Table.to_pandas()
converts ints to doubles #43112