Skip to content

Commit 628a3b0

Browse files
committed
use is_scalar
1 parent 33665e2 commit 628a3b0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pandas/core/col.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
Any,
1010
)
1111

12+
from pandas.core.dtypes.common import is_scalar
13+
1214
from pandas.core.series import Series
1315

1416
if TYPE_CHECKING:
@@ -32,9 +34,9 @@ def __init__(self, func: Callable[[DataFrame], Any]) -> None:
3234

3335
def __call__(self, df: DataFrame) -> Series:
3436
result = self._func(df)
35-
if not isinstance(result, Series):
37+
if not (isinstance(result, Series) or is_scalar(result)):
3638
msg = (
37-
"Expected function which returns Series, "
39+
"Expected function which returns Series or scalar, "
3840
f"got function which returns: {type(result)}"
3941
)
4042
raise TypeError(msg)

0 commit comments

Comments
 (0)