Skip to content

Commit c03cc55

Browse files
committed
move whatsnew to breaking changes, revert non-central test diff
1 parent f5b262b commit c03cc55

File tree

2 files changed

+21
-32
lines changed

2 files changed

+21
-32
lines changed

doc/source/whatsnew/v0.23.0.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,7 @@ Other API Changes
585585
- Set operations (union, difference...) on :class:`IntervalIndex` with incompatible index types will now raise a ``TypeError`` rather than a ``ValueError`` (:issue:`19329`)
586586
- :class:`DateOffset` objects render more simply, e.g. "<DateOffset: days=1>" instead of "<DateOffset: kwds={'days': 1}>" (:issue:`19403`)
587587
- :func:`pandas.merge` provides a more informative error message when trying to merge on timezone-aware and timezone-naive columns (:issue:`15800`)
588+
- Boolean operations ``&, |, ^`` between a ``Series`` and an ``Index`` will no longer raise ``TypeError`` (:issue:`19792`)
588589

589590
.. _whatsnew_0230.deprecations:
590591

@@ -866,4 +867,3 @@ Other
866867
^^^^^
867868

868869
- Improved error message when attempting to use a Python keyword as an identifier in a ``numexpr`` backed query (:issue:`18221`)
869-
- Boolean operations ``&, |, ^`` between a ``Series`` and an ``Index`` will no longer raise ``TypeError`` (:issue:`19792`)

pandas/tests/series/test_operators.py

+20-31
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import operator
1010
from itertools import product, starmap
1111

12+
from numpy import nan, inf
1213
import numpy as np
1314
import pandas as pd
1415

@@ -669,7 +670,7 @@ def test_floordiv_div(self):
669670
ser = Series([-1, 0, 1], name='first')
670671

671672
result = ser // 0
672-
expected = Series([-np.inf, np.nan, np.inf], name='first')
673+
expected = Series([-inf, nan, inf], name='first')
673674
assert_series_equal(result, expected)
674675

675676

@@ -1068,17 +1069,17 @@ def test_timedelta64_ops_nat(self):
10681069
assert_series_equal(1.5 * timedelta_series,
10691070
Series([NaT, Timedelta('1.5s')]))
10701071

1071-
assert_series_equal(timedelta_series * np.nan,
1072+
assert_series_equal(timedelta_series * nan,
10721073
nat_series_dtype_timedelta)
1073-
assert_series_equal(np.nan * timedelta_series,
1074+
assert_series_equal(nan * timedelta_series,
10741075
nat_series_dtype_timedelta)
10751076

10761077
# division
10771078
assert_series_equal(timedelta_series / 2,
10781079
Series([NaT, Timedelta('0.5s')]))
10791080
assert_series_equal(timedelta_series / 2.0,
10801081
Series([NaT, Timedelta('0.5s')]))
1081-
assert_series_equal(timedelta_series / np.nan,
1082+
assert_series_equal(timedelta_series / nan,
10821083
nat_series_dtype_timedelta)
10831084

10841085
def test_td64_sub_NaT(self):
@@ -1853,21 +1854,10 @@ def test_operators_bitwise_int_series_with_float_series(self):
18531854
result = s_0123 & Series([0.1, 4, -3.14, 2])
18541855
assert_series_equal(result, s_ftft)
18551856

1856-
@pytest.mark.xfail(reason='GH#19792 Series op doesnt support categorical')
1857-
def test_operators_bitwise_with_int_categorical(self):
1858-
# GH#9016: support bitwise op for integer types
1859-
# GH#??? allow for operating with Index
1860-
s_0123 = Series(range(4), dtype='int64').astype('category')
1861-
s_3333 = Series([3] * 4).astype('category')
1862-
1863-
res = s_0123 & pd.Categorical(s_3333)
1864-
expected = Series(range(4), dtype='int64').astype('category')
1865-
assert_series_equal(res, expected)
1866-
18671857
@pytest.mark.parametrize('box', [np.array, pd.Index, pd.Series])
18681858
def test_operators_bitwise_with_int_arraylike(self, box):
18691859
# GH#9016: support bitwise op for integer types
1870-
# GH#??? allow for operating with Index
1860+
# GH#19795 allow for operating with Index
18711861
s_0123 = Series(range(4), dtype='int64')
18721862
s_3333 = Series([3] * 4)
18731863
s_4444 = Series([4] * 4)
@@ -1902,19 +1892,21 @@ def test_operators_bitwise_with_integers(self):
19021892
s_fff = Series([False, False, False], index=index)
19031893
s_0123 = Series(range(4), dtype='int64')
19041894

1905-
res = s_tft & 0
1895+
n0 = 0
1896+
res = s_tft & n0
19061897
expected = s_fff
19071898
assert_series_equal(res, expected)
19081899

1909-
res = s_0123 & 0
1900+
res = s_0123 & n0
19101901
expected = Series([0] * 4)
19111902
assert_series_equal(res, expected)
19121903

1913-
res = s_tft & 1
1904+
n1 = 1
1905+
res = s_tft & n1
19141906
expected = s_tft
19151907
assert_series_equal(res, expected)
19161908

1917-
res = s_0123 & 1
1909+
res = s_0123 & n1
19181910
expected = Series([0, 1, 0, 1])
19191911
assert_series_equal(res, expected)
19201912

@@ -1952,19 +1944,16 @@ def test_operators_bitwise_with_reindexing(self):
19521944
# unable to sort incompatible object via .union.
19531945
exp = Series([False] * 7, index=['b', 'c', 'a', 0, 1, 2, 3])
19541946
with tm.assert_produces_warning(RuntimeWarning):
1955-
result = s_tft & s_0123
1956-
assert_series_equal(result, exp)
1947+
assert_series_equal(s_tft & s_0123, exp)
19571948
else:
19581949
exp = Series([False] * 7, index=[0, 1, 2, 3, 'a', 'b', 'c'])
1959-
result = s_tft & s_0123
1960-
assert_series_equal(result, exp)
1950+
assert_series_equal(s_tft & s_0123, exp)
19611951

19621952
# s_tft will be all false now because of reindexing like s_0123
19631953
if compat.PY3:
19641954
# unable to sort incompatible object via .union.
19651955
exp = Series([False] * 7, index=[0, 1, 2, 3, 'b', 'c', 'a'])
19661956
with tm.assert_produces_warning(RuntimeWarning):
1967-
result = s_0123 & s_tft
19681957
assert_series_equal(s_0123 & s_tft, exp)
19691958
else:
19701959
exp = Series([False] * 7, index=[0, 1, 2, 3, 'a', 'b', 'c'])
@@ -1980,9 +1969,9 @@ def test_operators_bitwise_with_nans(self):
19801969

19811970
s_ftft = Series([False, True, False, True])
19821971
s_abNd = Series(['a', 'b', np.NaN, 'd'])
1983-
result = s_0123 & s_abNd
1972+
res = s_0123 & s_abNd
19841973
expected = s_ftft
1985-
assert_series_equal(result, expected)
1974+
assert_series_equal(res, expected)
19861975

19871976
def test_scalar_na_cmp_corners(self):
19881977
s = Series([2, 3, 4, 5, 6, 7, 8, 9, 10])
@@ -2193,12 +2182,12 @@ def _check_fill(meth, op, a, b, fill_value=0):
21932182
with np.errstate(all='ignore'):
21942183
if amask[i]:
21952184
if bmask[i]:
2196-
exp_values.append(np.nan)
2185+
exp_values.append(nan)
21972186
continue
21982187
exp_values.append(op(fill_value, b[i]))
21992188
elif bmask[i]:
22002189
if amask[i]:
2201-
exp_values.append(np.nan)
2190+
exp_values.append(nan)
22022191
continue
22032192
exp_values.append(op(a[i], fill_value))
22042193
else:
@@ -2208,8 +2197,8 @@ def _check_fill(meth, op, a, b, fill_value=0):
22082197
expected = Series(exp_values, exp_index)
22092198
assert_series_equal(result, expected)
22102199

2211-
a = Series([np.nan, 1., 2., 3., np.nan], index=np.arange(5))
2212-
b = Series([np.nan, 1, np.nan, 3, np.nan, 4.], index=np.arange(6))
2200+
a = Series([nan, 1., 2., 3., nan], index=np.arange(5))
2201+
b = Series([nan, 1, nan, 3, nan, 4.], index=np.arange(6))
22132202

22142203
pairings = []
22152204
for op in ['add', 'sub', 'mul', 'pow', 'truediv', 'floordiv']:

0 commit comments

Comments
 (0)