Skip to content

Commit e5845ae

Browse files
louisjbrockmendel
louis
authored andcommitted
TST: Test for fix of type issue in empty groupby from DataFrame with categorical.
1 parent 14e5d67 commit e5845ae

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

pandas/tests/reshape/test_concat.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2747,14 +2747,18 @@ def test_concat_categorical_tz():
27472747
tm.assert_series_equal(result, expected)
27482748

27492749

2750-
def test_concat_categorical_unch():
2750+
def test_concat_categorical_unchanged():
27512751
# GH-12007
2752-
df1 = pd.DataFrame(pd.Series(["a", "b", "c"], dtype="category"))
2753-
s1 = pd.Series([0, 1, 2], index=[0, 1, 3])
2754-
df2 = pd.concat([df1, s1], axis=1)
2755-
result = df2.dtypes
2756-
expected = pd.Series(["category", "float64"], index=[0, 0])
2757-
tm.assert_series_equal(result, expected)
2752+
df = pd.DataFrame(pd.Series(["a", "b", "c"], dtype="category", name="A"))
2753+
ser = pd.Series([0, 1, 2], index=[0, 1, 3], name="B")
2754+
result = pd.concat([df, ser], axis=1)
2755+
expected = pd.DataFrame(
2756+
{
2757+
"A": pd.Series(["a", "b", "c", np.nan], dtype="category"),
2758+
"B": pd.Series([0, 1, np.nan, 2], dtype="float"),
2759+
}
2760+
)
2761+
tm.assert_equal(result, expected)
27582762

27592763

27602764
def test_concat_datetimeindex_freq():

0 commit comments

Comments
 (0)