diff --git a/pandas/tests/reshape/test_concat.py b/pandas/tests/reshape/test_concat.py index b537200dd7664..46dafbc4e1ec8 100644 --- a/pandas/tests/reshape/test_concat.py +++ b/pandas/tests/reshape/test_concat.py @@ -2747,6 +2747,22 @@ def test_concat_categorical_tz(): tm.assert_series_equal(result, expected) +def test_concat_categorical_unchanged(): + # GH-12007 + # test fix for when concat on categorical and float + # coerces dtype categorical -> float + df = pd.DataFrame(pd.Series(["a", "b", "c"], dtype="category", name="A")) + ser = pd.Series([0, 1, 2], index=[0, 1, 3], name="B") + result = pd.concat([df, ser], axis=1) + expected = pd.DataFrame( + { + "A": pd.Series(["a", "b", "c", np.nan], dtype="category"), + "B": pd.Series([0, 1, np.nan, 2], dtype="float"), + } + ) + tm.assert_equal(result, expected) + + def test_concat_datetimeindex_freq(): # GH 3232 # Monotonic index result