Skip to content

Commit 62cd9b7

Browse files
more fixes for infer_string mode
1 parent 33ef0d5 commit 62cd9b7

File tree

7 files changed

+14
-15
lines changed

7 files changed

+14
-15
lines changed

pandas/tests/dtypes/test_concat.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def test_concat_periodarray_2d():
4747
_concat.concat_compat([arr[:2], arr[2:]], axis=1)
4848

4949

50-
def test_concat_series_between_empty_and_tzaware_series():
50+
def test_concat_series_between_empty_and_tzaware_series(using_infer_string):
5151
tzaware_time = pd.Timestamp("2020-01-01T00:00:00+00:00")
5252
ser1 = Series(index=[tzaware_time], data=0, dtype=float)
5353
ser2 = Series(dtype=float)
@@ -57,7 +57,9 @@ def test_concat_series_between_empty_and_tzaware_series():
5757
data=[
5858
(0.0, None),
5959
],
60-
index=pd.Index([tzaware_time], dtype=object),
60+
index=[tzaware_time]
61+
if using_infer_string
62+
else pd.Index([tzaware_time], dtype=object),
6163
columns=[0, 1],
6264
dtype=float,
6365
)

pandas/tests/frame/constructors/test_from_dict.py

Lines changed: 0 additions & 3 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
from pandas import (
97
DataFrame,
108
Index,
@@ -44,7 +42,6 @@ def test_constructor_single_row(self):
4442
)
4543
tm.assert_frame_equal(result, expected)
4644

47-
@pytest.mark.xfail(using_string_dtype(), reason="columns inferring logic broken")
4845
def test_constructor_list_of_series(self):
4946
data = [
5047
OrderedDict([["a", 1.5], ["b", 3.0], ["c", 4.0]]),

pandas/tests/frame/test_constructors.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
from numpy.ma import mrecords
2222
import pytest
2323

24-
from pandas._config import using_string_dtype
25-
2624
from pandas._libs import lib
2725
from pandas.compat.numpy import np_version_gt2
2826
from pandas.errors import IntCastingNaNError
@@ -1974,7 +1972,6 @@ def test_constructor_with_datetimes4(self):
19741972
df = DataFrame({"value": dr})
19751973
assert str(df.iat[0, 0].tz) == "US/Eastern"
19761974

1977-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
19781975
def test_constructor_with_datetimes5(self):
19791976
# GH 7822
19801977
# preserver an index with a tz on dict construction

pandas/tests/indexes/base_class/test_setops.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ def test_tuple_union_bug(self, method, expected, sort):
240240
def test_union_name_preservation(
241241
self, first_list, second_list, first_name, second_name, expected_name, sort
242242
):
243-
# expected_dtype = object if not first_list or not second_list else "str"
244243
first = Index(first_list, name=first_name)
245244
second = Index(second_list, name=second_name)
246245
union = first.union(second, sort=sort)

pandas/tests/indexes/datetimes/test_join.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,17 @@ def test_join_utc_convert(self, join_type):
7070
assert isinstance(result, DatetimeIndex)
7171
assert result.tz is timezone.utc
7272

73-
def test_datetimeindex_union_join_empty(self, sort):
73+
def test_datetimeindex_union_join_empty(self, sort, using_infer_string):
7474
dti = date_range(start="1/1/2001", end="2/1/2001", freq="D")
7575
empty = Index([])
7676

7777
result = dti.union(empty, sort=sort)
78-
expected = dti.astype("O")
79-
tm.assert_index_equal(result, expected)
78+
if using_infer_string:
79+
assert isinstance(result, DatetimeIndex)
80+
tm.assert_index_equal(result, dti)
81+
else:
82+
expected = dti.astype("O")
83+
tm.assert_index_equal(result, expected)
8084

8185
result = dti.join(empty)
8286
assert isinstance(result, DatetimeIndex)

pandas/tests/indexing/test_loc.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2000,7 +2000,6 @@ def test_loc_setitem_datetime_keys_cast(self, conv, using_infer_string):
20002000
df.loc[conv(dt1), "one"] = 100
20012001
df.loc[conv(dt2), "one"] = 200
20022002

2003-
# breakpoint()
20042003
expected = DataFrame(
20052004
{"one": [100.0, 200.0]},
20062005
index=Index(

pandas/tests/series/methods/test_combine_first.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def test_combine_first_name(self, datetime_series):
3131
result = datetime_series.combine_first(datetime_series[:5])
3232
assert result.name == datetime_series.name
3333

34-
def test_combine_first(self):
34+
def test_combine_first(self, using_infer_string):
3535
values = np.arange(20, dtype=np.float64)
3636
series = Series(values, index=np.arange(20, dtype=np.int64))
3737

@@ -64,7 +64,8 @@ def test_combine_first(self):
6464
ser = Series([1.0, 2, 3], index=[0, 1, 2])
6565
empty = Series([], index=[], dtype=object)
6666
result = ser.combine_first(empty)
67-
ser.index = ser.index.astype("O")
67+
if not using_infer_string:
68+
ser.index = ser.index.astype("O")
6869
tm.assert_series_equal(result, ser.astype(object))
6970

7071
def test_combine_first_dt64(self, unit):

0 commit comments

Comments
 (0)