Skip to content

Commit 1295868

Browse files
committed
BUG: GH39443 - categorical datetime concat
1 parent b4e9566 commit 1295868

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

pandas/tests/reshape/concat/test_categorical.py

+18
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from datetime import datetime
2+
13
import numpy as np
24

35
from pandas.core.dtypes.dtypes import CategoricalDtype
@@ -202,3 +204,19 @@ def test_categorical_concat_gh7864(self):
202204

203205
dfa = df1.append(df2)
204206
tm.assert_index_equal(df["grade"].cat.categories, dfa["grade"].cat.categories)
207+
208+
def test_categorical_datetime_concat(self):
209+
# GH 39443
210+
df1 = DataFrame(
211+
{"x": Series(datetime(2021, 1, 1), index=[0], dtype="category")}
212+
)
213+
df2 = DataFrame(
214+
{"x": Series(datetime(2021, 1, 2), index=[1], dtype="category")}
215+
)
216+
217+
result = pd.concat([df1, df2])
218+
expected = DataFrame(
219+
{"x": Series([datetime(2021, 1, 1), datetime(2021, 1, 2)])}
220+
)
221+
222+
tm.assert_equal(result, expected)

0 commit comments

Comments
 (0)