Skip to content

Commit 288f06e

Browse files
committed
fix(comment): #62191 (comment)
1 parent f60bf95 commit 288f06e

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

pandas/core/ops/docstrings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ def make_flex_doc(op_name: str, typ: str) -> str:
435435
436436
Parameters
437437
----------
438-
other : Series or scalar value (that can be the element of a Series)
438+
other : Array-like or scalar value (non-array-like element of the former)
439439
The second operand in this operation.
440440
level : int or name
441441
Broadcast across a level, matching Index values on the

pandas/core/series.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6072,7 +6072,7 @@ def eq(
60726072
60736073
Parameters
60746074
----------
6075-
other : Series or scalar value (that can be the element of a Series)
6075+
other : Array-like or scalar value (non-array-like element of the former)
60766076
The second operand in this operation.
60776077
level : int or name
60786078
Broadcast across a level, matching Index values on the
@@ -6141,7 +6141,7 @@ def le(self, other, level=None, fill_value=None, axis: Axis = 0) -> Series:
61416141
61426142
Parameters
61436143
----------
6144-
other : Series or scalar value (that can be the element of a Series)
6144+
other : Array-like or scalar value (non-array-like element of the former)
61456145
The second operand in this operation.
61466146
level : int or name
61476147
Broadcast across a level, matching Index values on the
@@ -6213,7 +6213,7 @@ def ge(self, other, level=None, fill_value=None, axis: Axis = 0) -> Series:
62136213
62146214
Parameters
62156215
----------
6216-
other : Series or scalar value (that can be the element of a Series)
6216+
other : Array-like or scalar value (non-array-like element of the former)
62176217
The second operand in this operation.
62186218
level : int or name
62196219
Broadcast across a level, matching Index values on the

pandas/tests/series/methods/test_compare.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
from enum import (
2+
Enum,
3+
auto,
4+
)
5+
16
import numpy as np
27
import pytest
38

@@ -138,3 +143,25 @@ def test_compare_datetime64_and_string():
138143
tm.assert_series_equal(result_eq1, expected_eq)
139144
tm.assert_series_equal(result_eq2, expected_eq)
140145
tm.assert_series_equal(result_neq, expected_neq)
146+
147+
148+
def test_eq_objects():
149+
class Thing(Enum):
150+
FIRST = auto()
151+
SECOND = auto()
152+
153+
left = pd.Series([Thing.FIRST, Thing.SECOND])
154+
tm.assert_series_equal(left.eq(Thing.FIRST), left == Thing.FIRST)
155+
156+
py_l = [Thing.FIRST, Thing.SECOND]
157+
tm.assert_series_equal(left.eq(py_l), left == py_l)
158+
159+
np_a = np.asarray(py_l)
160+
tm.assert_series_equal(left.eq(np_a), left == np_a)
161+
162+
pd_s = pd.Series(py_l)
163+
tm.assert_series_equal(left.eq(pd_s), left == pd_s)
164+
165+
left_non_scalar = pd.Series([[1, 2], [3, 4]])
166+
with pytest.raises(AssertionError):
167+
tm.assert_series_equal(left_non_scalar.eq([1, 2]), pd.Series([True, False]))

0 commit comments

Comments
 (0)