Skip to content

Commit 509c74c

Browse files
committed
Fix test_mixed_col_index_dtype
1 parent 2d8b55e commit 509c74c

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

pandas/tests/frame/test_arithmetic.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import numpy as np
1212
import pytest
1313

14-
from pandas.compat import HAS_PYARROW
14+
import pandas.util._test_decorators as td
1515

1616
import pandas as pd
1717
from pandas import (
@@ -2183,18 +2183,28 @@ def test_enum_column_equality():
21832183
tm.assert_series_equal(result, expected)
21842184

21852185

2186-
def test_mixed_col_index_dtype():
2186+
@pytest.mark.parametrize(
2187+
"dtype",
2188+
[
2189+
"string[python]",
2190+
pytest.param(
2191+
pd.StringDtype(storage="pyarrow", na_value=pd.NA),
2192+
marks=td.skip_if_no("pyarrow"),
2193+
),
2194+
pytest.param(
2195+
pd.StringDtype(storage="pyarrow", na_value=np.nan),
2196+
marks=td.skip_if_no("pyarrow"),
2197+
),
2198+
],
2199+
)
2200+
def test_mixed_col_index_dtype(dtype):
21872201
# GH 47382
21882202
df1 = DataFrame(columns=list("abc"), data=1.0, index=[0])
21892203
df2 = DataFrame(columns=list("abc"), data=0.0, index=[0])
2190-
df1.columns = df2.columns.astype("string")
2204+
df1.columns = df2.columns.astype(dtype)
21912205
result = df1 + df2
21922206
expected = DataFrame(columns=list("abc"), data=1.0, index=[0])
21932207

2194-
if HAS_PYARROW:
2195-
dtype = "string[pyarrow]"
2196-
else:
2197-
dtype = "string"
21982208
expected.columns = expected.columns.astype(dtype)
21992209

22002210
tm.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)