Skip to content

TST: Add test to check category dtype remains unchanged after concat. #29352

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 4 commits into from
Nov 12, 2019
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
16 changes: 16 additions & 0 deletions pandas/tests/reshape/test_concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2747,6 +2747,22 @@ def test_concat_categorical_tz():
tm.assert_series_equal(result, expected)


def test_concat_categorical_unchanged():
# GH-12007
# test fix for when concat on categorical and float
# coerces dtype categorical -> float
df = pd.DataFrame(pd.Series(["a", "b", "c"], dtype="category", name="A"))
ser = pd.Series([0, 1, 2], index=[0, 1, 3], name="B")
result = pd.concat([df, ser], axis=1)
expected = pd.DataFrame(
{
"A": pd.Series(["a", "b", "c", np.nan], dtype="category"),
"B": pd.Series([0, 1, np.nan, 2], dtype="float"),
}
)
tm.assert_equal(result, expected)


def test_concat_datetimeindex_freq():
# GH 3232
# Monotonic index result
Expand Down