@@ -119,6 +119,31 @@ def test_update(self):
119
119
# this will fail as long as series is a sub-class of ndarray
120
120
# df['c'].update(Series(['foo'],index=[0])) #####
121
121
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
+
122
147
def test_concat_empty_series_dtypes_roundtrips (self ):
123
148
124
149
# round-tripping with self & like self
0 commit comments