Skip to content

Commit e6e4971

Browse files
author
Carlos Souza
committed
Adding replace unicode with number and replace mixed types with string tests
1 parent bd31b2b commit e6e4971

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

pandas/tests/series/test_replace.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,23 @@ def test_replace_with_empty_dictlike(self):
227227
tm.assert_series_equal(s, s.replace(dict()))
228228
tm.assert_series_equal(s, s.replace(pd.Series([])))
229229

230-
def test_replace_string_with_nan(self):
230+
def test_replace_string_with_number(self):
231231
# GH 15743
232232
s = pd.Series([1, 2, 3])
233233
result = s.replace('2', np.nan)
234234
expected = pd.Series([1, 2, 3])
235235
tm.assert_series_equal(expected, result)
236+
237+
def test_replace_unicode_with_number(self):
238+
# GH 15743
239+
s = pd.Series([1, 2, 3])
240+
result = s.replace(u'2', np.nan)
241+
expected = pd.Series([1, 2, 3])
242+
tm.assert_series_equal(expected, result)
243+
244+
def test_replace_mixed_types_with_string(self):
245+
# Testing mixed
246+
s = pd.Series([1, 2, 3, '4', 4, 5])
247+
result = s.replace([2, '4'], np.nan)
248+
expected = pd.Series([1, np.nan, 3, np.nan, 4, 5])
249+
tm.assert_series_equal(expected, result)

0 commit comments

Comments
 (0)