Skip to content

Commit ce5e887

Browse files
a few more
1 parent f96fc03 commit ce5e887

File tree

4 files changed

+18
-19
lines changed

4 files changed

+18
-19
lines changed

pandas/tests/series/accessors/test_dt_accessor.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
import numpy as np
1111
import pytest
1212

13-
from pandas._config import using_string_dtype
14-
1513
from pandas._libs.tslibs.timezones import maybe_get_tz
1614

1715
from pandas.core.dtypes.common import (

pandas/tests/series/indexing/test_where.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import numpy as np
22
import pytest
33

4-
from pandas._config import using_string_dtype
5-
64
from pandas.core.dtypes.common import is_integer
75

86
import pandas as pd
@@ -231,7 +229,6 @@ def test_where_ndframe_align():
231229
tm.assert_series_equal(out, expected)
232230

233231

234-
@pytest.mark.xfail(using_string_dtype(), reason="can't set ints into string")
235232
def test_where_setitem_invalid():
236233
# GH 2702
237234
# make sure correct exceptions are raised on invalid list assignment
@@ -241,7 +238,7 @@ def test_where_setitem_invalid():
241238
"different length than the value"
242239
)
243240
# slice
244-
s = Series(list("abc"))
241+
s = Series(list("abc"), dtype=object)
245242

246243
with pytest.raises(ValueError, match=msg("slice")):
247244
s[0:3] = list(range(27))
@@ -251,18 +248,18 @@ def test_where_setitem_invalid():
251248
tm.assert_series_equal(s.astype(np.int64), expected)
252249

253250
# slice with step
254-
s = Series(list("abcdef"))
251+
s = Series(list("abcdef"), dtype=object)
255252

256253
with pytest.raises(ValueError, match=msg("slice")):
257254
s[0:4:2] = list(range(27))
258255

259-
s = Series(list("abcdef"))
256+
s = Series(list("abcdef"), dtype=object)
260257
s[0:4:2] = list(range(2))
261258
expected = Series([0, "b", 1, "d", "e", "f"])
262259
tm.assert_series_equal(s, expected)
263260

264261
# neg slices
265-
s = Series(list("abcdef"))
262+
s = Series(list("abcdef"), dtype=object)
266263

267264
with pytest.raises(ValueError, match=msg("slice")):
268265
s[:-1] = list(range(27))
@@ -272,18 +269,18 @@ def test_where_setitem_invalid():
272269
tm.assert_series_equal(s, expected)
273270

274271
# list
275-
s = Series(list("abc"))
272+
s = Series(list("abc"), dtype=object)
276273

277274
with pytest.raises(ValueError, match=msg("list-like")):
278275
s[[0, 1, 2]] = list(range(27))
279276

280-
s = Series(list("abc"))
277+
s = Series(list("abc"), dtype=object)
281278

282279
with pytest.raises(ValueError, match=msg("list-like")):
283280
s[[0, 1, 2]] = list(range(2))
284281

285282
# scalar
286-
s = Series(list("abc"))
283+
s = Series(list("abc"), dtype=object)
287284
s[0] = list(range(10))
288285
expected = Series([list(range(10)), "b", "c"])
289286
tm.assert_series_equal(s, expected)

pandas/tests/series/methods/test_replace.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import numpy as np
44
import pytest
55

6-
from pandas._config import using_string_dtype
7-
86
import pandas as pd
97
import pandas._testing as tm
108
from pandas.core.arrays import IntervalArray
@@ -628,15 +626,23 @@ def test_replace_nullable_numeric(self):
628626
with pytest.raises(TypeError, match="Invalid value"):
629627
ints.replace(1, 9.5)
630628

631-
@pytest.mark.xfail(using_string_dtype(), reason="can't fill 1 in string")
632629
@pytest.mark.parametrize("regex", [False, True])
633630
def test_replace_regex_dtype_series(self, regex):
634631
# GH-48644
635-
series = pd.Series(["0"])
632+
series = pd.Series(["0"], dtype=object)
636633
expected = pd.Series([1], dtype=object)
637634
result = series.replace(to_replace="0", value=1, regex=regex)
638635
tm.assert_series_equal(result, expected)
639636

637+
@pytest.mark.parametrize("regex", [False, True])
638+
def test_replace_regex_dtype_series_string(self, regex, using_infer_string):
639+
if not using_infer_string:
640+
# then this is object dtype which is already tested above
641+
return
642+
series = pd.Series(["0"], dtype="str")
643+
with pytest.raises(TypeError, match="Invalid value"):
644+
series.replace(to_replace="0", value=1, regex=regex)
645+
640646
def test_replace_different_int_types(self, any_int_numpy_dtype):
641647
# GH#45311
642648
labs = pd.Series([1, 1, 1, 0, 0, 2, 2, 2], dtype=any_int_numpy_dtype)
@@ -667,7 +673,7 @@ def test_replace_change_dtype_series(self):
667673
df["Test"] = df["Test"].replace([None], [np.nan])
668674
tm.assert_frame_equal(df, expected)
669675

670-
df = pd.DataFrame({"Test": ["0.5", None, "0.6"]}, dtype=object)
676+
df = pd.DataFrame({"Test": ["0.5", None, "0.6"]}, dtype=object)
671677
df["Test"] = df["Test"].fillna(np.nan)
672678
tm.assert_frame_equal(df, expected)
673679

pandas/tests/series/methods/test_unstack.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import numpy as np
22
import pytest
33

4-
from pandas._config import using_string_dtype
5-
64
import pandas as pd
75
from pandas import (
86
DataFrame,

0 commit comments

Comments
 (0)