From 1913841d081c4b6d4b64ed9fcedf836270fbed3e Mon Sep 17 00:00:00 2001 From: RajatS Mukherjee Date: Fri, 30 Jun 2023 16:36:08 +0000 Subject: [PATCH] Added unit-test --- .../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 14c559db4b0b5..2730b2ffcc4e3 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 @@ -166,6 +168,22 @@ def test_concat_categorical_tz(self): ) tm.assert_series_equal(result, expected) + def test_concat_categorical_datetime(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) + def test_concat_categorical_unchanged(self): # GH-12007 # test fix for when concat on categorical and float