Skip to content

Commit a669d75

Browse files
update tests
1 parent bb148ba commit a669d75

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

pandas/tests/frame/test_arithmetic.py

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

14-
from pandas._config import using_string_dtype
15-
1614
import pandas as pd
1715
from pandas import (
1816
DataFrame,
@@ -2101,12 +2099,21 @@ def test_enum_column_equality():
21012099
tm.assert_series_equal(result, expected)
21022100

21032101

2104-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
2105-
def test_mixed_col_index_dtype():
2102+
def test_mixed_col_index_dtype(any_string_dtype):
21062103
# GH 47382
2107-
df1 = DataFrame(columns=list("abc"), data=1.0, index=[0])
2108-
df2 = DataFrame(columns=list("abc"), data=0.0, index=[0])
2109-
df1.columns = df2.columns.astype("string")
2104+
df1 = DataFrame(
2105+
columns=Index(list("abc"), dtype=any_string_dtype), data=1.0, index=[0]
2106+
)
2107+
df2 = DataFrame(columns=Index(list("abc"), dtype="object"), data=0.0, index=[0])
2108+
21102109
result = df1 + df2
2111-
expected = DataFrame(columns=list("abc"), data=1.0, index=[0])
2110+
expected = DataFrame(
2111+
columns=Index(list("abc"), dtype=any_string_dtype), data=1.0, index=[0]
2112+
)
2113+
tm.assert_frame_equal(result, expected)
2114+
2115+
result = df2 + df1
2116+
expected = DataFrame(
2117+
columns=Index(list("abc"), dtype="object"), data=1.0, index=[0]
2118+
)
21122119
tm.assert_frame_equal(result, expected)

pandas/tests/reshape/test_pivot.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2664,6 +2664,8 @@ def test_pivot_columns_not_given(self):
26642664
with pytest.raises(TypeError, match="missing 1 required keyword-only argument"):
26652665
df.pivot()
26662666

2667+
# this still fails because columns=None gets passed down to unstack as level=None
2668+
# while at that point None was converted to NaN
26672669
@pytest.mark.xfail(
26682670
using_string_dtype(), reason="TODO(infer_string) None is cast to NaN"
26692671
)
@@ -2682,10 +2684,7 @@ def test_pivot_columns_is_none(self):
26822684
expected = DataFrame({1: 3}, index=Index([2], name="b"))
26832685
tm.assert_frame_equal(result, expected)
26842686

2685-
@pytest.mark.xfail(
2686-
using_string_dtype(), reason="TODO(infer_string) None is cast to NaN"
2687-
)
2688-
def test_pivot_index_is_none(self):
2687+
def test_pivot_index_is_none(self, using_infer_string):
26892688
# GH#48293
26902689
df = DataFrame({None: [1], "b": 2, "c": 3})
26912690

@@ -2696,6 +2695,8 @@ def test_pivot_index_is_none(self):
26962695

26972696
result = df.pivot(columns="b", index=None, values="c")
26982697
expected = DataFrame(3, index=[1], columns=Index([2], name="b"))
2698+
if using_infer_string:
2699+
expected.index.name = np.nan
26992700
tm.assert_frame_equal(result, expected)
27002701

27012702
def test_pivot_values_is_none(self):

0 commit comments

Comments
 (0)