Skip to content

Commit 802f6ac

Browse files
committed
Add further tests for Series case
1 parent e1abe77 commit 802f6ac

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

pandas/tests/series/test_combine_concat.py

+25
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,31 @@ def test_update(self):
119119
# this will fail as long as series is a sub-class of ndarray
120120
# df['c'].update(Series(['foo'],index=[0])) #####
121121

122+
def test_update_nooverwrite(self):
123+
s = Series([0, 1, 2, np.nan, np.nan, 5, 6, np.nan])
124+
other = Series([1, 3, np.nan, 7, 9], index=[1, 3, 5, 7, 9])
125+
126+
s.update(other, overwrite=False)
127+
128+
expected = Series([0, 1, 2, 3, np.nan, 5, 6, 7])
129+
assert_series_equal(s, expected)
130+
131+
def test_update_filtered(self):
132+
s = Series(np.arange(8), dtype='int64')
133+
other = Series(np.arange(8), dtype='int64') + 10
134+
135+
s.update(other, filter_func=lambda x: x % 2 == 1)
136+
137+
expected = Series([0, 11, 2, 13, 4, 15, 6, 17])
138+
assert_series_equal(s, expected)
139+
140+
def test_update_raise(self):
141+
s = Series([0, 1, 2, np.nan, np.nan, 5, 6, np.nan])
142+
other = Series([1, 3, np.nan, 7, 9], index=[1, 3, 5, 7, 9])
143+
144+
with tm.assert_raises_regex(ValueError, "Data overlaps"):
145+
s.update(other, errors='raise')
146+
122147
def test_concat_empty_series_dtypes_roundtrips(self):
123148

124149
# round-tripping with self & like self

0 commit comments

Comments
 (0)