From 1295868b5b2c97150ce2e4163c0f6af7bb37274e Mon Sep 17 00:00:00 2001 From: arredond Date: Tue, 20 Apr 2021 22:51:17 +0200 Subject: [PATCH] BUG: GH39443 - categorical datetime concat --- .../tests/reshape/concat/test_categorical.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pandas/tests/reshape/concat/test_categorical.py b/pandas/tests/reshape/concat/test_categorical.py index a81085e083199..a852c1c91331d 100644 --- a/pandas/tests/reshape/concat/test_categorical.py +++ b/pandas/tests/reshape/concat/test_categorical.py @@ -1,3 +1,5 @@ +from datetime import datetime + import numpy as np from pandas.core.dtypes.dtypes import CategoricalDtype @@ -202,3 +204,19 @@ def test_categorical_concat_gh7864(self): dfa = df1.append(df2) tm.assert_index_equal(df["grade"].cat.categories, dfa["grade"].cat.categories) + + def test_categorical_datetime_concat(self): + # GH 39443 + df1 = DataFrame( + {"x": Series(datetime(2021, 1, 1), index=[0], dtype="category")} + ) + df2 = DataFrame( + {"x": Series(datetime(2021, 1, 2), index=[1], dtype="category")} + ) + + result = pd.concat([df1, df2]) + expected = DataFrame( + {"x": Series([datetime(2021, 1, 1), datetime(2021, 1, 2)])} + ) + + tm.assert_equal(result, expected)