|
11 | 11 | import numpy as np
|
12 | 12 | import pytest
|
13 | 13 |
|
14 |
| -from pandas.compat import HAS_PYARROW |
| 14 | +import pandas.util._test_decorators as td |
15 | 15 |
|
16 | 16 | import pandas as pd
|
17 | 17 | from pandas import (
|
@@ -2183,18 +2183,28 @@ def test_enum_column_equality():
|
2183 | 2183 | tm.assert_series_equal(result, expected)
|
2184 | 2184 |
|
2185 | 2185 |
|
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): |
2187 | 2201 | # GH 47382
|
2188 | 2202 | df1 = DataFrame(columns=list("abc"), data=1.0, index=[0])
|
2189 | 2203 | df2 = DataFrame(columns=list("abc"), data=0.0, index=[0])
|
2190 |
| - df1.columns = df2.columns.astype("string") |
| 2204 | + df1.columns = df2.columns.astype(dtype) |
2191 | 2205 | result = df1 + df2
|
2192 | 2206 | expected = DataFrame(columns=list("abc"), data=1.0, index=[0])
|
2193 | 2207 |
|
2194 |
| - if HAS_PYARROW: |
2195 |
| - dtype = "string[pyarrow]" |
2196 |
| - else: |
2197 |
| - dtype = "string" |
2198 | 2208 | expected.columns = expected.columns.astype(dtype)
|
2199 | 2209 |
|
2200 | 2210 | tm.assert_frame_equal(result, expected)
|
0 commit comments