-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Bug: Fix Inconsistent Behavior for Series.searchsorted #49706
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
Merged
Merged
Changes from 20 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
ab4e851
Bug: Fix inconsistent behavior in searchsorted (#49620)
yqyqyq-W 8e33f8e
Merge branch 'pandas-dev:main' into main
yqyqyq-W 60d05d6
Merge branch 'pandas-dev:main' into main
yqyqyq-W 0b1b450
Update v2.0.0.rst
yqyqyq-W f043fb5
Merge branch 'main' of https://github.com/yqyqyq-W/pandas
yqyqyq-W edd6099
Revert "Update v2.0.0.rst"
yqyqyq-W 340de9a
Update whatsnew
yqyqyq-W 06337f6
Update v2.0.0.rst
yqyqyq-W 090bd79
Update base.py
yqyqyq-W 56b3fba
Revert "Update base.py"
yqyqyq-W 12db40d
Bug: Fix inconsistent behavior in searchsorted (#49620)
yqyqyq-W 34ecabc
Update whatsnew
yqyqyq-W b2053d8
Merge branch 'pandas-dev:main' into main
yqyqyq-W 023a7c7
Bug: Fix inconsistent behavior in searchsorted (#49620)
yqyqyq-W 9037cc9
Add test for failure on DataFrame
yqyqyq-W 72f809c
Merge branch 'main' of https://github.com/yqyqyq-W/pandas
yqyqyq-W 063fddb
Merge branch 'pandas-dev:main' into main
yqyqyq-W 2a70a16
Add test for failure on DataFrame
yqyqyq-W bdd9a26
Add test for failure on DataFrame
yqyqyq-W f83189c
Add test for failure on DataFrame
yqyqyq-W 2f85075
Bug: Fix inconsistent behavior in searchsorted (#49620)
yqyqyq-W 7558c3d
Add test for failure on DataFrame
yqyqyq-W 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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import numpy as np | ||
import pytest | ||
|
||
import pandas as pd | ||
from pandas import ( | ||
Series, | ||
Timestamp, | ||
|
@@ -65,3 +67,10 @@ def test_searchsorted_sorter(self): | |
res = ser.searchsorted([0, 3], sorter=np.argsort(ser)) | ||
exp = np.array([0, 2], dtype=np.intp) | ||
tm.assert_numpy_array_equal(res, exp) | ||
|
||
def test_searchsorted_Dataframe_fail(self): | ||
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. can you de-capitalize "DataFrame" here, and add a comment |
||
ser = Series([1, 2, 3, 4, 5]) | ||
vals = pd.DataFrame([[1, 2], [3, 4]]) | ||
msg = "Value must be array-like or scalar, DataFrame is not supported" | ||
with pytest.raises(ValueError, match=msg): | ||
ser.searchsorted(vals) |
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 "1D" 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.
I have added 1-D. In fact, n-D object except DataFrame works well with this function. As long as we don't call
pd.array(n-d DataFrame)
.