Skip to content

Commit b27ee0f

Browse files
rsm-23im-vinicius
authored and
im-vinicius
committed
TST: Concatenating categorical datetime columns (pandas-dev#53949)
Added unit-test
1 parent 7605126 commit b27ee0f

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
@@ -166,6 +168,22 @@ def test_concat_categorical_tz(self):
166168
)
167169
tm.assert_series_equal(result, expected)
168170

171+
def test_concat_categorical_datetime(self):
172+
# GH-39443
173+
df1 = DataFrame(
174+
{"x": Series(datetime(2021, 1, 1), index=[0], dtype="category")}
175+
)
176+
df2 = DataFrame(
177+
{"x": Series(datetime(2021, 1, 2), index=[1], dtype="category")}
178+
)
179+
180+
result = pd.concat([df1, df2])
181+
expected = DataFrame(
182+
{"x": Series([datetime(2021, 1, 1), datetime(2021, 1, 2)])}
183+
)
184+
185+
tm.assert_equal(result, expected)
186+
169187
def test_concat_categorical_unchanged(self):
170188
# GH-12007
171189
# test fix for when concat on categorical and float

0 commit comments

Comments
 (0)