Skip to content

Commit 6e7c5cd

Browse files
WillAydjorisvandenbossche
authored andcommitted
TST(string dtype): Fix xfails in test_block_internals.py (pandas-dev#60765)
(cherry picked from commit d38706a)
1 parent 9b0e866 commit 6e7c5cd

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
from pandas.errors import PerformanceWarning
1311
import pandas.util._test_decorators as td
1412

@@ -185,21 +183,7 @@ def test_constructor_with_convert(self):
185183
)
186184
tm.assert_series_equal(result, expected)
187185

188-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
189186
def test_construction_with_mixed(self, float_string_frame, using_infer_string):
190-
# test construction edge cases with mixed types
191-
192-
# f7u12, this does not work without extensive workaround
193-
data = [
194-
[datetime(2001, 1, 5), np.nan, datetime(2001, 1, 2)],
195-
[datetime(2000, 1, 2), datetime(2000, 1, 3), datetime(2000, 1, 1)],
196-
]
197-
df = DataFrame(data)
198-
199-
# check dtypes
200-
result = df.dtypes
201-
expected = Series({"datetime64[us]": 3})
202-
203187
# mixed-type frames
204188
float_string_frame["datetime"] = datetime.now()
205189
float_string_frame["timedelta"] = timedelta(days=1, seconds=1)
@@ -219,13 +203,11 @@ def test_construction_with_mixed(self, float_string_frame, using_infer_string):
219203
)
220204
tm.assert_series_equal(result, expected)
221205

222-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
223206
def test_construction_with_conversions(self):
224207
# convert from a numpy array of non-ns timedelta64; as of 2.0 this does
225208
# *not* convert
226209
arr = np.array([1, 2, 3], dtype="timedelta64[s]")
227-
df = DataFrame(index=range(3))
228-
df["A"] = arr
210+
df = DataFrame({"A": arr})
229211
expected = DataFrame(
230212
{"A": pd.timedelta_range("00:00:01", periods=3, freq="s")}, index=range(3)
231213
)
@@ -243,11 +225,11 @@ def test_construction_with_conversions(self):
243225
assert expected.dtypes["dt1"] == "M8[s]"
244226
assert expected.dtypes["dt2"] == "M8[s]"
245227

246-
df = DataFrame(index=range(3))
247-
df["dt1"] = np.datetime64("2013-01-01")
248-
df["dt2"] = np.array(
228+
dt1 = np.datetime64("2013-01-01")
229+
dt2 = np.array(
249230
["2013-01-01", "2013-01-02", "2013-01-03"], dtype="datetime64[D]"
250231
)
232+
df = DataFrame({"dt1": dt1, "dt2": dt2})
251233

252234
# df['dt3'] = np.array(['2013-01-01 00:00:01','2013-01-01
253235
# 00:00:02','2013-01-01 00:00:03'],dtype='datetime64[s]')
@@ -440,14 +422,17 @@ def test_update_inplace_sets_valid_block_values(using_copy_on_write):
440422
assert df.isnull().sum().sum() == 0
441423

442424

443-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
444425
def test_nonconsolidated_item_cache_take():
445426
# https://github.com/pandas-dev/pandas/issues/35521
446427

447428
# create non-consolidated dataframe with object dtype columns
448-
df = DataFrame()
449-
df["col1"] = Series(["a"], dtype=object)
429+
df = DataFrame(
430+
{
431+
"col1": Series(["a"], dtype=object),
432+
}
433+
)
450434
df["col2"] = Series([0], dtype=object)
435+
assert not df._mgr.is_consolidated()
451436

452437
# access column (item cache)
453438
df["col1"] == "A"

0 commit comments

Comments
 (0)