-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Fixes unwanted casting in .isin (GH21804) #21893
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
Closed
Closed
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
d0c7ebc
Merge pull request #1 from pandas-dev/master
KalyanGokhale 143566a
Merge pull request #3 from pandas-dev/master
KalyanGokhale dd60b4e
Merge pull request #4 from pandas-dev/master
KalyanGokhale 3209172
Revert "22May"
KalyanGokhale 18751ba
Merge pull request #5 from KalyanGokhale/revert-4-master
KalyanGokhale 031616d
Merge pull request #6 from pandas-dev/master
KalyanGokhale 9d92a76
For Rebasing
KalyanGokhale d8b5242
Merge branch 'master' of https://github.com/pandas-dev/pandas into pa…
KalyanGokhale 050f80a
Merge branch 'pandas-dev-master'
KalyanGokhale 3aa8561
Update 13Jul18
KalyanGokhale ee66578
Initial commit
KalyanGokhale 84be606
Replaced list with generator
KalyanGokhale f8cc271
Code restructure
KalyanGokhale b71dad6
Code restructing, included missing element
KalyanGokhale 5416711
Cleaned removed ifs for int_flg and float_flg
KalyanGokhale 9fca52c
Using existing type check functions
KalyanGokhale dd37f9c
Revert "Using existing type check functions"
KalyanGokhale 52f8131
Remove flgs and retain try-except
KalyanGokhale 63a5f15
Remove flgs
KalyanGokhale 2e0bb49
Remove flg, fix whatsnew
KalyanGokhale 82386c3
Whatsnew updated
KalyanGokhale 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 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -509,42 +509,23 @@ def test_invalid(self): | |
pytest.raises(TypeError, lambda: algos.isin(1, [1])) | ||
pytest.raises(TypeError, lambda: algos.isin([1], 1)) | ||
|
||
def test_basic(self): | ||
|
||
result = algos.isin([1, 2], [1]) | ||
expected = np.array([True, False]) | ||
tm.assert_numpy_array_equal(result, expected) | ||
|
||
result = algos.isin(np.array([1, 2]), [1]) | ||
expected = np.array([True, False]) | ||
tm.assert_numpy_array_equal(result, expected) | ||
|
||
result = algos.isin(Series([1, 2]), [1]) | ||
expected = np.array([True, False]) | ||
tm.assert_numpy_array_equal(result, expected) | ||
|
||
result = algos.isin(Series([1, 2]), Series([1])) | ||
expected = np.array([True, False]) | ||
tm.assert_numpy_array_equal(result, expected) | ||
|
||
result = algos.isin(Series([1, 2]), set([1])) | ||
expected = np.array([True, False]) | ||
tm.assert_numpy_array_equal(result, expected) | ||
|
||
result = algos.isin(['a', 'b'], ['a']) | ||
expected = np.array([True, False]) | ||
tm.assert_numpy_array_equal(result, expected) | ||
|
||
result = algos.isin(Series(['a', 'b']), Series(['a'])) | ||
expected = np.array([True, False]) | ||
tm.assert_numpy_array_equal(result, expected) | ||
|
||
result = algos.isin(Series(['a', 'b']), set(['a'])) | ||
expected = np.array([True, False]) | ||
tm.assert_numpy_array_equal(result, expected) | ||
|
||
result = algos.isin(['a', 'b'], [1]) | ||
expected = np.array([False, False]) | ||
@pytest.mark.parametrize("comps,values,expected", [ | ||
([1, 2], [1], [True, False]), | ||
([1, 0], [1, 0.5], [True, False]), | ||
([1.0, 0], [1, 0.5], [True, False]), | ||
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. To reviewers: Just for reference, here are the new tests. @KalyanGokhale : Nice refactoring! 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. Thanks @gfyoung |
||
([1.0, 0.0], [1, 0], [True, True]), | ||
(np.array([1, 2]), [1], [True, False]), | ||
(Series([1, 2]), [1], [True, False]), | ||
(Series([1, 2]), Series([1]), [True, False]), | ||
(Series([1, 2]), set([1]), [True, False]), | ||
(['a', 'b'], ['a'], [True, False]), | ||
(Series(['a', 'b']), Series(['a']), [True, False]), | ||
(Series(['a', 'b']), set(['a']), [True, False]), | ||
(['a', 'b'], [1], [False, False]) | ||
]) | ||
def test_basic(self, comps, values, expected): | ||
result = algos.isin(comps, values) | ||
expected = np.array(expected) | ||
tm.assert_numpy_array_equal(result, expected) | ||
|
||
def test_i8(self): | ||
|
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.
i already indicate that this is not the path forward
this is much slower than the existing
you need to keep it along the current structure
and post benchmarks
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.
@jreback Thanks - have removed the flags
int_flg
/float_flg
as suggested per your earlier review and posted the benchmarks after each commit.Re-pasting the benchmarks after the last commit
Also, could not get around writing a custom function
is_time_like
- had tried it in9fca52c
Please feel free to close this PR - since I think I am not sure I understand what is the expectation in terms of maintaining the existing structure
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.
there are many benchmarks
the point is that this code is highly sensistive to changes and requires a lot of benchmark running to avoid regressions