Skip to content

Commit fcbcb5b

Browse files
author
Giacomo Ferroni
committed
Apply review changes
1 parent eb7d9fd commit fcbcb5b

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
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-
- Not boolean Series returned by comparison methods (e.g., ``lt``, ``gt``, ...) against a constant for an empty DataFrame (:issue:`15077`)
365+
- Incorrect dtyped ``Series`` was returned by comparison methods (e.g., ``lt``, ``gt``, ...) against a constant for an empty ``DataFrame`` (:issue:`15077`)

pandas/tests/frame/test_operators.py

+4-10
Original file line numberDiff line numberDiff line change
@@ -678,20 +678,14 @@ def test_return_dtypes_bool_op_costant(self):
678678

679679
# not empty DataFrame
680680
for op in ['eq', 'ne', 'gt', 'lt', 'ge', 'le']:
681-
f = getattr(df, op)
682-
for col in ['x', 'y']:
683-
res = f(const)
684-
c = getattr(res, col)
685-
self.assertEqual(c.dtypes, bool)
681+
result = getattr(df, op)(const).get_dtype_counts()
682+
self.assert_series_equal(result, Series([2], ['bool']))
686683

687684
# empty DataFrame
688685
empty = df.iloc[:0]
689686
for op in ['eq', 'ne', 'gt', 'lt', 'ge', 'le']:
690-
f = getattr(empty, op)
691-
for col in ['x', 'y']:
692-
res = f(const)
693-
c = getattr(res, col)
694-
self.assertEqual(c.dtypes, bool)
687+
result = getattr(empty, op)(const).get_dtype_counts()
688+
self.assert_series_equal(result, Series([2], ['bool']))
695689

696690
def test_dti_tz_convert_to_utc(self):
697691
base = pd.DatetimeIndex(['2011-01-01', '2011-01-02',

pandas/tests/series/test_operators.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -1297,15 +1297,16 @@ def test_comparison_flex_alignment_fill(self):
12971297
def test_return_dtypes_bool_op_costant(self):
12981298
# gh15115
12991299
s = pd.Series([1, 3, 2], index=range(3))
1300+
const = 2
13001301
for op in ['eq', 'ne', 'gt', 'lt', 'ge', 'le']:
1301-
f = getattr(s, op)
1302-
self.assertFalse(f(2).dtypes, np.dtype('bool'))
1302+
result = getattr(s, op)(const).get_dtype_counts()
1303+
self.assert_series_equal(result, Series([1], ['bool']))
13031304

13041305
# empty Series
13051306
empty = s.iloc[:0]
13061307
for op in ['eq', 'ne', 'gt', 'lt', 'ge', 'le']:
1307-
f = getattr(empty, op)
1308-
self.assertFalse(f(2).dtypes, np.dtype('bool'))
1308+
result = getattr(empty, op)(const).get_dtype_counts()
1309+
self.assert_series_equal(result, Series([1], ['bool']))
13091310

13101311
def test_operators_bitwise(self):
13111312
# GH 9016: support bitwise op for integer types

0 commit comments

Comments
 (0)