Skip to content

Commit d38706a

Browse files
authored
TST(string dtype): Fix xfails in test_block_internals.py (#60765)
1 parent c168883 commit d38706a

File tree

3 files changed

+11
-27
lines changed

3 files changed

+11
-27
lines changed

pandas/tests/frame/conftest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def float_string_frame():
3333
df = DataFrame(
3434
np.random.default_rng(2).standard_normal((30, 4)),
3535
index=Index([f"foo_{i}" for i in range(30)], dtype=object),
36-
columns=Index(list("ABCD"), dtype=object),
36+
columns=Index(list("ABCD")),
3737
)
3838
df["foo"] = "bar"
3939
return df

pandas/tests/frame/constructors/test_from_dict.py

-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ def test_constructor_list_of_series(self):
108108
expected = DataFrame.from_dict(sdict, orient="index")
109109
tm.assert_frame_equal(result, expected)
110110

111-
@pytest.mark.xfail(using_string_dtype(), reason="columns inferring logic broken")
112111
def test_constructor_orient(self, float_string_frame):
113112
data_dict = float_string_frame.T._series
114113
recons = DataFrame.from_dict(data_dict, orient="index")

pandas/tests/frame/test_block_internals.py

+10-25
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
import numpy as np
88
import pytest
99

10-
from pandas._config import using_string_dtype
11-
1210
import pandas as pd
1311
from pandas import (
1412
Categorical,
@@ -162,21 +160,7 @@ def test_constructor_with_convert(self):
162160
)
163161
tm.assert_series_equal(result, expected)
164162

165-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
166163
def test_construction_with_mixed(self, float_string_frame, using_infer_string):
167-
# test construction edge cases with mixed types
168-
169-
# f7u12, this does not work without extensive workaround
170-
data = [
171-
[datetime(2001, 1, 5), np.nan, datetime(2001, 1, 2)],
172-
[datetime(2000, 1, 2), datetime(2000, 1, 3), datetime(2000, 1, 1)],
173-
]
174-
df = DataFrame(data)
175-
176-
# check dtypes
177-
result = df.dtypes
178-
expected = Series({"datetime64[us]": 3})
179-
180164
# mixed-type frames
181165
float_string_frame["datetime"] = datetime.now()
182166
float_string_frame["timedelta"] = timedelta(days=1, seconds=1)
@@ -196,13 +180,11 @@ def test_construction_with_mixed(self, float_string_frame, using_infer_string):
196180
)
197181
tm.assert_series_equal(result, expected)
198182

199-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
200183
def test_construction_with_conversions(self):
201184
# convert from a numpy array of non-ns timedelta64; as of 2.0 this does
202185
# *not* convert
203186
arr = np.array([1, 2, 3], dtype="timedelta64[s]")
204-
df = DataFrame(index=range(3))
205-
df["A"] = arr
187+
df = DataFrame({"A": arr})
206188
expected = DataFrame(
207189
{"A": pd.timedelta_range("00:00:01", periods=3, freq="s")}, index=range(3)
208190
)
@@ -220,11 +202,11 @@ def test_construction_with_conversions(self):
220202
assert expected.dtypes["dt1"] == "M8[s]"
221203
assert expected.dtypes["dt2"] == "M8[s]"
222204

223-
df = DataFrame(index=range(3))
224-
df["dt1"] = np.datetime64("2013-01-01")
225-
df["dt2"] = np.array(
205+
dt1 = np.datetime64("2013-01-01")
206+
dt2 = np.array(
226207
["2013-01-01", "2013-01-02", "2013-01-03"], dtype="datetime64[D]"
227208
)
209+
df = DataFrame({"dt1": dt1, "dt2": dt2})
228210

229211
# df['dt3'] = np.array(['2013-01-01 00:00:01','2013-01-01
230212
# 00:00:02','2013-01-01 00:00:03'],dtype='datetime64[s]')
@@ -401,14 +383,17 @@ def test_update_inplace_sets_valid_block_values():
401383
assert isinstance(df._mgr.blocks[0].values, Categorical)
402384

403385

404-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
405386
def test_nonconsolidated_item_cache_take():
406387
# https://github.com/pandas-dev/pandas/issues/35521
407388

408389
# create non-consolidated dataframe with object dtype columns
409-
df = DataFrame()
410-
df["col1"] = Series(["a"], dtype=object)
390+
df = DataFrame(
391+
{
392+
"col1": Series(["a"], dtype=object),
393+
}
394+
)
411395
df["col2"] = Series([0], dtype=object)
396+
assert not df._mgr.is_consolidated()
412397

413398
# access column (item cache)
414399
df["col1"] == "A"

0 commit comments

Comments
 (0)