Skip to content

Commit 4693d1a

Browse files
authored
TST(string dtype): Resolve xfails in test_to_csv (#60683)
1 parent 3aba767 commit 4693d1a

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

pandas/tests/frame/methods/test_astype.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ def test_astype_tz_object_conversion(self, tz):
745745
result = result.astype({"tz": "datetime64[ns, Europe/London]"})
746746
tm.assert_frame_equal(result, expected)
747747

748-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
748+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string) GH#60639")
749749
def test_astype_dt64_to_string(
750750
self, frame_or_series, tz_naive_fixture, using_infer_string
751751
):

pandas/tests/frame/methods/test_reset_index.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ def test_rest_index_multiindex_categorical_with_missing_values(self, codes):
644644
tm.assert_frame_equal(res, expected)
645645

646646

647-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
647+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string) - GH#60338")
648648
@pytest.mark.parametrize(
649649
"array, dtype",
650650
[

pandas/tests/frame/methods/test_to_csv.py

+4-10
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
import numpy as np
66
import pytest
77

8-
from pandas._config import using_string_dtype
9-
108
from pandas.errors import ParserError
119

1210
import pandas as pd
@@ -438,20 +436,18 @@ def test_to_csv_empty(self):
438436
result, expected = self._return_result_expected(df, 1000)
439437
tm.assert_frame_equal(result, expected, check_column_type=False)
440438

441-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
442439
@pytest.mark.slow
443440
def test_to_csv_chunksize(self):
444441
chunksize = 1000
445442
rows = chunksize // 2 + 1
446443
df = DataFrame(
447444
np.ones((rows, 2)),
448-
columns=Index(list("ab"), dtype=object),
445+
columns=Index(list("ab")),
449446
index=MultiIndex.from_arrays([range(rows) for _ in range(2)]),
450447
)
451448
result, expected = self._return_result_expected(df, chunksize, rnlvl=2)
452449
tm.assert_frame_equal(result, expected, check_names=False)
453450

454-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
455451
@pytest.mark.slow
456452
@pytest.mark.parametrize(
457453
"nrows", [2, 10, 99, 100, 101, 102, 198, 199, 200, 201, 202, 249, 250, 251]
@@ -480,7 +476,7 @@ def test_to_csv_params(self, nrows, df_params, func_params, ncols):
480476
for _ in range(df_params["c_idx_nlevels"])
481477
)
482478
else:
483-
columns = Index([f"i-{i}" for i in range(ncols)], dtype=object)
479+
columns = Index([f"i-{i}" for i in range(ncols)])
484480
df = DataFrame(np.ones((nrows, ncols)), index=index, columns=columns)
485481
result, expected = self._return_result_expected(df, 1000, **func_params)
486482
tm.assert_frame_equal(result, expected, check_names=False)
@@ -738,7 +734,6 @@ def test_to_csv_withcommas(self, temp_file):
738734
df2 = self.read_csv(path)
739735
tm.assert_frame_equal(df2, df)
740736

741-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
742737
def test_to_csv_mixed(self, temp_file):
743738
def create_cols(name):
744739
return [f"{name}{i:03d}" for i in range(5)]
@@ -755,7 +750,7 @@ def create_cols(name):
755750
)
756751
df_bool = DataFrame(True, index=df_float.index, columns=create_cols("bool"))
757752
df_object = DataFrame(
758-
"foo", index=df_float.index, columns=create_cols("object")
753+
"foo", index=df_float.index, columns=create_cols("object"), dtype="object"
759754
)
760755
df_dt = DataFrame(
761756
Timestamp("20010101"),
@@ -824,13 +819,12 @@ def test_to_csv_dups_cols(self, temp_file):
824819
result.columns = df.columns
825820
tm.assert_frame_equal(result, df)
826821

827-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
828822
def test_to_csv_dups_cols2(self, temp_file):
829823
# GH3457
830824
df = DataFrame(
831825
np.ones((5, 3)),
832826
index=Index([f"i-{i}" for i in range(5)], name="foo"),
833-
columns=Index(["a", "a", "b"], dtype=object),
827+
columns=Index(["a", "a", "b"]),
834828
)
835829

836830
path = str(temp_file)

0 commit comments

Comments
 (0)