Skip to content

Commit

Permalink
Backport PR pandas-dev#60683: TST(string dtype): Resolve xfails in te…
Browse files Browse the repository at this point in the history
…st_to_csv
  • Loading branch information
rhshadrach authored and WillAyd committed Jan 9, 2025
1 parent 65c1a54 commit 7417f5e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pandas/tests/frame/methods/test_astype.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ def test_astype_tz_object_conversion(self, tz):
result = result.astype({"tz": "datetime64[ns, Europe/London]"})
tm.assert_frame_equal(result, expected)

@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string) GH#60639")
def test_astype_dt64_to_string(
self, frame_or_series, tz_naive_fixture, using_infer_string
):
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/frame/methods/test_reset_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ def test_rest_index_multiindex_categorical_with_missing_values(self, codes):
tm.assert_frame_equal(res, expected)


@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string) - GH#60338")
@pytest.mark.parametrize(
"array, dtype",
[
Expand Down
14 changes: 4 additions & 10 deletions pandas/tests/frame/methods/test_to_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import numpy as np
import pytest

from pandas._config import using_string_dtype

from pandas.errors import ParserError

import pandas as pd
Expand Down Expand Up @@ -422,20 +420,18 @@ def test_to_csv_empty(self):
result, expected = self._return_result_expected(df, 1000)
tm.assert_frame_equal(result, expected, check_column_type=False)

@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
@pytest.mark.slow
def test_to_csv_chunksize(self):
chunksize = 1000
rows = chunksize // 2 + 1
df = DataFrame(
np.ones((rows, 2)),
columns=Index(list("ab"), dtype=object),
columns=Index(list("ab")),
index=MultiIndex.from_arrays([range(rows) for _ in range(2)]),
)
result, expected = self._return_result_expected(df, chunksize, rnlvl=2)
tm.assert_frame_equal(result, expected, check_names=False)

@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
@pytest.mark.slow
@pytest.mark.parametrize(
"nrows", [2, 10, 99, 100, 101, 102, 198, 199, 200, 201, 202, 249, 250, 251]
Expand Down Expand Up @@ -464,7 +460,7 @@ def test_to_csv_params(self, nrows, df_params, func_params, ncols):
for _ in range(df_params["c_idx_nlevels"])
)
else:
columns = Index([f"i-{i}" for i in range(ncols)], dtype=object)
columns = Index([f"i-{i}" for i in range(ncols)])
df = DataFrame(np.ones((nrows, ncols)), index=index, columns=columns)
result, expected = self._return_result_expected(df, 1000, **func_params)
tm.assert_frame_equal(result, expected, check_names=False)
Expand Down Expand Up @@ -722,7 +718,6 @@ def test_to_csv_withcommas(self):
df2 = self.read_csv(path)
tm.assert_frame_equal(df2, df)

@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
def test_to_csv_mixed(self):
def create_cols(name):
return [f"{name}{i:03d}" for i in range(5)]
Expand All @@ -739,7 +734,7 @@ def create_cols(name):
)
df_bool = DataFrame(True, index=df_float.index, columns=create_cols("bool"))
df_object = DataFrame(
"foo", index=df_float.index, columns=create_cols("object")
"foo", index=df_float.index, columns=create_cols("object"), dtype="object"
)
df_dt = DataFrame(
Timestamp("20010101").as_unit("ns"),
Expand Down Expand Up @@ -812,13 +807,12 @@ def test_to_csv_dups_cols(self):
result.columns = df.columns
tm.assert_frame_equal(result, df)

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

with tm.ensure_clean() as filename:
Expand Down

0 comments on commit 7417f5e

Please sign in to comment.