-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
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
BUG: support casting from bool array to EA Integer dtype #25265
Merged
jreback
merged 22 commits into
pandas-dev:master
from
vladserkoff:integer-array-from-bool
May 14, 2019
Merged
Changes from 20 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
0c97445
BUG: support casting from bool array to EA Integer dtype
vladserkoff b3e1d76
only cast bool to int if target dtype is interger type
vladserkoff ed61191
Merge branch 'master' into integer-array-from-bool
vladserkoff c80d4cd
add test to #25265
vladserkoff 9c2877a
fix missing parameter to the test to #25265
vladserkoff 697852d
pass dtype to integer_array to the test to #25265
vladserkoff c9c4d87
add another test case
vladserkoff c313cca
add note to watsnew
vladserkoff d0acd20
Merge branch 'master' into integer-array-from-bool
vladserkoff 7c24ea8
Fix passing result_dtype as string
vladserkoff c18cf28
Merge branch 'master' into integer-array-from-bool
vladserkoff 54431e4
possible fix for integer_array with dtype=None
vladserkoff 986548f
fix pep8
vladserkoff c21412c
add test cases with dtype=None
vladserkoff 775114a
fix tests
vladserkoff cb207aa
fix pep8
vladserkoff e6655bc
quickfix failing s.combine on extention array
vladserkoff 96fa493
fix for infering dtype in failing s.combine on extention array
vladserkoff 089a72a
fix for infering dtype in failing s.combine on extention array
vladserkoff f2e2eac
Merge branch 'master' into integer-array-from-bool
vladserkoff 99a6678
Merge branch 'master' into integer-array-from-bool
vladserkoff 3bce8a1
revert to c18cf28
vladserkoff File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -187,6 +187,9 @@ def coerce_to_array(values, dtype, mask=None, copy=False): | |||
raise TypeError("{} cannot be converted to an IntegerDtype".format( | ||||
values.dtype)) | ||||
|
||||
elif is_bool_dtype(values) and (is_integer_dtype(dtype) or dtype is None): | ||||
values = np.array(values, dtype=int, copy=copy) | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. np.asarray? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's like in other places in the code, e.g. pandas/pandas/core/arrays/integer.py Line 179 in f2e2eac
|
||||
|
||||
elif not (is_integer_dtype(values) or is_float_dtype(values)): | ||||
raise TypeError("{} cannot be converted to an IntegerDtype".format( | ||||
values.dtype)) | ||||
|
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
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
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
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.
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.
can you add a 1-line comment here on acceptable dtypes
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.
Ok?
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.
looking more for the reason we need to check here
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.
more about the reason you need to check, and when/how dtype is None
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.
How about this? Couldn't fit it into one line, though.