Skip to content

TST: Concatenating categorical datetime columns #53949

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions pandas/tests/reshape/concat/test_categorical.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from datetime import datetime

import numpy as np

from pandas.core.dtypes.dtypes import CategoricalDtype
Expand Down Expand Up @@ -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
Expand Down