Skip to content

Commit d794618

Browse files
committed
TST: add tests for dict with bool keys
1 parent 818adb0 commit d794618

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

pandas/tests/test_frame.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8003,6 +8003,12 @@ def test_replace_bool_with_bool(self):
80038003
expected = DataFrame(np.ones((2, 2), dtype=bool))
80048004
tm.assert_frame_equal(result, expected)
80058005

8006+
def test_replace_with_dict_with_bool_keys(self):
8007+
df = DataFrame({0: [True, False], 1: [False, True]})
8008+
result = df.replace({'asdf': 'asdb', True: 'yes'})
8009+
expected = DataFrame({0: ['yes', False], 1: [False, 'yes']})
8010+
tm.assert_frame_equal(expected, result)
8011+
80068012
def test_combine_multiple_frames_dtypes(self):
80078013
from pandas import concat
80088014

pandas/tests/test_series.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5291,7 +5291,6 @@ def test_replace(self):
52915291
result = ser.replace(Timestamp('20130103'), Timestamp('20120101'))
52925292
assert_series_equal(result, expected)
52935293

5294-
52955294
def test_replace_with_single_list(self):
52965295
ser = Series([0, 1, 2, 3, 4])
52975296
result = ser.replace([1,2,3])
@@ -5307,6 +5306,7 @@ def test_replace_with_single_list(self):
53075306
s.replace([1,2,3],inplace=True,method='crash_cymbal')
53085307
assert_series_equal(s, ser)
53095308

5309+
53105310
def test_replace_mixed_types(self):
53115311
s = Series(np.arange(5),dtype='int64')
53125312

@@ -5367,6 +5367,12 @@ def test_replace_bool_with_bool(self):
53675367
expected = Series([False] * len(s))
53685368
tm.assert_series_equal(expected, result)
53695369

5370+
def test_replace_with_dict_with_bool_keys(self):
5371+
s = Series([True, False, True])
5372+
result = s.replace({'asdf': 'asdb', True: 'yes'})
5373+
expected = Series(['yes', False, 'yes'])
5374+
tm.assert_series_equal(expected, result)
5375+
53705376
def test_asfreq(self):
53715377
ts = Series([0., 1., 2.], index=[datetime(2009, 10, 30),
53725378
datetime(2009, 11, 30),

0 commit comments

Comments
 (0)