Skip to content

Commit e998d7c

Browse files
committed
Adjust according to comments
1 parent ef5c259 commit e998d7c

File tree

5 files changed

+17
-4
lines changed

5 files changed

+17
-4
lines changed

doc/source/whatsnew/v0.24.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,7 @@ Other API Changes
10081008
- Slicing a single row of a DataFrame with multiple ExtensionArrays of the same type now preserves the dtype, rather than coercing to object (:issue:`22784`)
10091009
- :class:`DateOffset` attribute `_cacheable` and method `_should_cache` have been removed (:issue:`23118`)
10101010
- Comparing :class:`Timedelta` to be less or greater than unknown types now raises a ``TypeError`` instead of returning ``False`` (:issue:`20829`)
1011-
- :meth:`Series.searchsorted`, when supplied a scalar value to search for, now returns a scalar instead of an array (:issue:`xxxxx`).
1011+
- :meth:`Series.searchsorted`, when supplied a scalar value to search for, now returns a scalar instead of an array (:issue:`23801`).
10121012
- :meth:`Categorical.searchsorted`, when supplied a scalar value to search for, now returns a scalar instead of an array (:issue:`23466`).
10131013
- :meth:`Categorical.searchsorted` now raises a ``KeyError`` rather that a ``ValueError``, if a searched for key is not found in its categories (:issue:`23466`).
10141014
- :meth:`Index.hasnans` and :meth:`Series.hasnans` now always return a python boolean. Previously, a python or a numpy boolean could be returned, depending on circumstances (:issue:`23294`).

pandas/core/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1212,7 +1212,7 @@ def factorize(self, sort=False, na_sentinel=-1):
12121212
same shape as `value`.
12131213
12141214
.. versionchanged :: 0.24.0
1215-
Ìf `value`is a scalar, an int is now always returned.
1215+
If `value` is a scalar, an int is now always returned.
12161216
Previously, scalar inputs returned an 1-item array for
12171217
:class:`Series` and :class:`Categorical`.
12181218

pandas/tests/indexes/common.py

+6
Original file line numberDiff line numberDiff line change
@@ -1036,22 +1036,28 @@ def test_searchsorted_monotonic(self, indices):
10361036
# test searchsorted only for increasing
10371037
if indices.is_monotonic_increasing:
10381038
ssm_left = indices._searchsorted_monotonic(value, side='left')
1039+
assert tm.is_scalar(ssm_left)
10391040
assert expected_left == ssm_left
10401041

10411042
ssm_right = indices._searchsorted_monotonic(value, side='right')
1043+
assert tm.is_scalar(ssm_right)
10421044
assert expected_right == ssm_right
10431045

10441046
ss_left = indices.searchsorted(value, side='left')
1047+
assert tm.is_scalar(ss_left)
10451048
assert expected_left == ss_left
10461049

10471050
ss_right = indices.searchsorted(value, side='right')
1051+
assert tm.is_scalar(ss_right)
10481052
assert expected_right == ss_right
10491053

10501054
elif indices.is_monotonic_decreasing:
10511055
ssm_left = indices._searchsorted_monotonic(value, side='left')
1056+
assert tm.is_scalar(ssm_left)
10521057
assert expected_left == ssm_left
10531058

10541059
ssm_right = indices._searchsorted_monotonic(value, side='right')
1060+
assert tm.is_scalar(ssm_right)
10551061
assert expected_right == ssm_right
10561062

10571063
else:

pandas/tests/indexes/multi/test_monotonic.py

+7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import pandas as pd
77
from pandas import Index, IntervalIndex, MultiIndex
8+
import pandas.util.testing as tm
89

910

1011
def test_is_monotonic_increasing():
@@ -182,22 +183,28 @@ def test_searchsorted_monotonic(indices):
182183
# test searchsorted only for increasing
183184
if indices.is_monotonic_increasing:
184185
ssm_left = indices._searchsorted_monotonic(value, side='left')
186+
assert tm.is_scalar(ssm_left)
185187
assert expected_left == ssm_left
186188

187189
ssm_right = indices._searchsorted_monotonic(value, side='right')
190+
assert tm.is_scalar(ssm_right)
188191
assert expected_right == ssm_right
189192

190193
ss_left = indices.searchsorted(value, side='left')
194+
assert tm.is_scalar(ss_left)
191195
assert expected_left == ss_left
192196

193197
ss_right = indices.searchsorted(value, side='right')
198+
assert tm.is_scalar(ss_right)
194199
assert expected_right == ss_right
195200

196201
elif indices.is_monotonic_decreasing:
197202
ssm_left = indices._searchsorted_monotonic(value, side='left')
203+
assert tm.is_scalar(ssm_left)
198204
assert expected_left == ssm_left
199205

200206
ssm_right = indices._searchsorted_monotonic(value, side='right')
207+
assert tm.is_scalar(ssm_right)
201208
assert expected_right == ssm_right
202209

203210
else:

pandas/util/testing.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
is_bool, is_categorical_dtype, is_datetime64_dtype, is_datetime64tz_dtype,
2828
is_datetimelike_v_numeric, is_datetimelike_v_object,
2929
is_extension_array_dtype, is_interval_dtype, is_list_like, is_number,
30-
is_period_dtype, is_scalar, is_sequence, is_timedelta64_dtype,
31-
needs_i8_conversion) # noqa
30+
is_period_dtype, is_sequence, is_timedelta64_dtype, needs_i8_conversion)
31+
from pandas.core.dtypes.common import is_scalar # noqa: F401
3232
from pandas.core.dtypes.missing import array_equivalent
3333

3434
import pandas as pd

0 commit comments

Comments
 (0)