Skip to content

Commit ab4e851

Browse files
committed
Bug: Fix inconsistent behavior in searchsorted (#49620)
Raise error when DataFrame is passed to searchsorted
1 parent c7010a7 commit ab4e851

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pandas/core/base.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import numpy as np
2222

23+
import pandas as pd
2324
from pandas._libs import lib
2425
from pandas._typing import (
2526
Axis,
@@ -1270,6 +1271,13 @@ def searchsorted(
12701271
sorter: NumpySorter = None,
12711272
) -> npt.NDArray[np.intp] | np.intp:
12721273

1274+
if isinstance(value, pd.DataFrame):
1275+
msg = (
1276+
"Value must be array-like or scalar, "
1277+
f"{type(value).__name__} is not supported"
1278+
)
1279+
raise ValueError(msg)
1280+
12731281
values = self._values
12741282
if not isinstance(values, np.ndarray):
12751283
# Going through EA.searchsorted directly improves performance GH#38083

0 commit comments

Comments
 (0)