Skip to content

Concatenating rows with Int64 datatype coerces to object #36278

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
Sep 13, 2020
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
9 changes: 9 additions & 0 deletions pandas/tests/reshape/test_concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2918,3 +2918,12 @@ def test_concat_frame_axis0_extension_dtypes():
result = pd.concat([df2, df1], ignore_index=True)
expected = pd.DataFrame({"a": [4, 5, 6, 1, 2, 3]}, dtype="Int64")
tm.assert_frame_equal(result, expected)


def test_concat_preserves_extension_int64_dtype():
# GH 24768
df_a = pd.DataFrame({"a": [-1]}, dtype="Int64")
df_b = pd.DataFrame({"b": [1]}, dtype="Int64")
result = pd.concat([df_a, df_b], ignore_index=True)
expected = pd.DataFrame({"a": [-1, None], "b": [None, 1]}, dtype="Int64")
tm.assert_frame_equal(result, expected)