Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions pandas/tests/frame/test_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,42 @@ def test_logical_with_nas(self):
expected = Series([True, True])
tm.assert_series_equal(result, expected)

@pytest.mark.parametrize(
"left, right, op, expected",
[
(
[True, False, np.nan],
[True, False, True],
operator.and_,
[True, False, False],
),
(
[True, False, True],
[True, False, np.nan],
operator.and_,
[True, False, False],
),
(
[True, False, np.nan],
[True, False, True],
operator.or_,
[True, False, False],
),
(
[True, False, True],
[True, False, np.nan],
operator.or_,
[True, False, True],
),
],
)
def test_logical_operators_nans(self, left, right, op, expected):
# GH 13896
result = op(DataFrame(left), DataFrame(right))
expected = DataFrame(expected)

tm.assert_frame_equal(result, expected)


class TestDataFrameOperators:
@pytest.mark.parametrize(
Expand Down
36 changes: 36 additions & 0 deletions pandas/tests/series/test_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,42 @@ def test_logical_operators_bool_dtype_with_empty(self):
expected = s_tft
tm.assert_series_equal(res, expected)

@pytest.mark.parametrize(
"left, right, op, expected",
[
(
[True, False, np.nan],
[True, False, True],
operator.and_,
[True, False, False],
),
(
[True, False, True],
[True, False, np.nan],
operator.and_,
[True, False, False],
),
(
[True, False, np.nan],
[True, False, True],
operator.or_,
[True, False, False],
),
(
[True, False, True],
[True, False, np.nan],
operator.or_,
[True, False, True],
),
],
)
def test_logical_operators_nans(self, left, right, op, expected):
# GH 13896
result = op(Series(left), Series(right))
expected = Series(expected)

tm.assert_series_equal(result, expected)

def test_logical_operators_int_dtype_with_int_dtype(self):
# GH#9016: support bitwise op for integer types

Expand Down