@@ -137,20 +137,15 @@ def test_replace_gh5319(self):
137
137
# API change from 0.12?
138
138
# GH 5319
139
139
ser = pd .Series ([0 , np .nan , 2 , 3 , 4 ])
140
- expected = ser .ffill ()
141
140
msg = (
142
- "Series.replace without 'value' and with non-dict-like "
143
- "'to_replace' is deprecated "
141
+ "Series.replace must specify either 'value', "
142
+ "a dict-like 'to_replace', or dict-like 'regex' "
144
143
)
145
- with tm .assert_produces_warning (FutureWarning , match = msg ):
146
- result = ser .replace ([np .nan ])
147
- tm .assert_series_equal (result , expected )
144
+ with pytest .raises (ValueError , match = msg ):
145
+ ser .replace ([np .nan ])
148
146
149
- ser = pd .Series ([0 , np .nan , 2 , 3 , 4 ])
150
- expected = ser .ffill ()
151
- with tm .assert_produces_warning (FutureWarning , match = msg ):
152
- result = ser .replace (np .nan )
153
- tm .assert_series_equal (result , expected )
147
+ with pytest .raises (ValueError , match = msg ):
148
+ ser .replace (np .nan )
154
149
155
150
def test_replace_datetime64 (self ):
156
151
# GH 5797
@@ -182,19 +177,16 @@ def test_replace_timedelta_td64(self):
182
177
183
178
def test_replace_with_single_list (self ):
184
179
ser = pd .Series ([0 , 1 , 2 , 3 , 4 ])
185
- msg2 = (
186
- "Series.replace without 'value' and with non-dict-like "
187
- "'to_replace' is deprecated "
180
+ msg = (
181
+ "Series.replace must specify either 'value', "
182
+ "a dict-like 'to_replace', or dict-like 'regex' "
188
183
)
189
- with tm .assert_produces_warning (FutureWarning , match = msg2 ):
190
- result = ser .replace ([1 , 2 , 3 ])
191
- tm .assert_series_equal (result , pd .Series ([0 , 0 , 0 , 0 , 4 ]))
184
+ with pytest .raises (ValueError , match = msg ):
185
+ ser .replace ([1 , 2 , 3 ])
192
186
193
187
s = ser .copy ()
194
- with tm .assert_produces_warning (FutureWarning , match = msg2 ):
195
- return_value = s .replace ([1 , 2 , 3 ], inplace = True )
196
- assert return_value is None
197
- tm .assert_series_equal (s , pd .Series ([0 , 0 , 0 , 0 , 4 ]))
188
+ with pytest .raises (ValueError , match = msg ):
189
+ s .replace ([1 , 2 , 3 ], inplace = True )
198
190
199
191
def test_replace_mixed_types (self ):
200
192
ser = pd .Series (np .arange (5 ), dtype = "int64" )
@@ -483,13 +475,8 @@ def test_replace_invalid_to_replace(self):
483
475
r"Expecting 'to_replace' to be either a scalar, array-like, "
484
476
r"dict or None, got invalid type.*"
485
477
)
486
- msg2 = (
487
- "Series.replace without 'value' and with non-dict-like "
488
- "'to_replace' is deprecated"
489
- )
490
478
with pytest .raises (TypeError , match = msg ):
491
- with tm .assert_produces_warning (FutureWarning , match = msg2 ):
492
- series .replace (lambda x : x .strip ())
479
+ series .replace (lambda x : x .strip ())
493
480
494
481
@pytest .mark .parametrize ("frame" , [False , True ])
495
482
def test_replace_nonbool_regex (self , frame ):
0 commit comments