Skip to content

Commit 28437bb

Browse files
author
Giacomo Ferroni
committed
Check for bool dtype return added also for Series.
Minor update to whatsnew
1 parent 19296f1 commit 28437bb

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

doc/source/whatsnew/v0.20.0.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -362,4 +362,4 @@ Bug Fixes
362362

363363

364364
- Bug in ``pd.read_csv()`` for the C engine where ``usecols`` were being indexed incorrectly with ``parse_dates`` (:issue:`14792`)
365-
- Bug in dtypes returned by comparison methods (e.g., ``lt``, ``gt``, ...) against a constant for an empty DataFrame (:issue:`15077`)
365+
- Not boolean Series returned by comparison methods (e.g., ``lt``, ``gt``, ...) against a constant for an empty DataFrame (:issue:`15077`)

pandas/tests/series/test_operators.py

+15
Original file line numberDiff line numberDiff line change
@@ -1224,6 +1224,8 @@ def test_comparison_label_based(self):
12241224
for v in [np.nan]:
12251225
self.assertRaises(TypeError, lambda: t & v)
12261226

1227+
1228+
12271229
def test_comparison_flex_basic(self):
12281230
left = pd.Series(np.random.randn(10))
12291231
right = pd.Series(np.random.randn(10))
@@ -1294,6 +1296,19 @@ def test_comparison_flex_alignment_fill(self):
12941296
exp = pd.Series([True, True, False, False], index=list('abcd'))
12951297
assert_series_equal(left.gt(right, fill_value=0), exp)
12961298

1299+
def test_return_dtypes_bool_op_costant(self):
1300+
# gh15115
1301+
s = pd.Series([1, 3, 2], index=range(3))
1302+
for op in ['eq', 'ne', 'gt', 'lt', 'ge', 'le']:
1303+
f = getattr(s, op)
1304+
self.assertFalse(f(2).dtypes, np.dtype('bool'))
1305+
1306+
# empty Series
1307+
empty = s.iloc[:0]
1308+
for op in ['eq', 'ne', 'gt', 'lt', 'ge', 'le']:
1309+
f = getattr(empty, op)
1310+
self.assertFalse(f(2).dtypes, np.dtype('bool'))
1311+
12971312
def test_operators_bitwise(self):
12981313
# GH 9016: support bitwise op for integer types
12991314
index = list('bca')

0 commit comments

Comments
 (0)