Skip to content

Commit 1b2f1f4

Browse files
authored
Concatenating rows with Int64 datatype coerces to object
1 parent 1f49b76 commit 1b2f1f4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pandas/tests/reshape/test_concat.py

+9
Original file line numberDiff line numberDiff line change
@@ -2918,3 +2918,12 @@ def test_concat_frame_axis0_extension_dtypes():
29182918
result = pd.concat([df2, df1], ignore_index=True)
29192919
expected = pd.DataFrame({"a": [4, 5, 6, 1, 2, 3]}, dtype="Int64")
29202920
tm.assert_frame_equal(result, expected)
2921+
2922+
2923+
def test_concat_preserves_extension_int64_dtype():
2924+
# GH 24768
2925+
df_a = pd.DataFrame({"a": [-1]}, dtype="Int64")
2926+
df_b = pd.DataFrame({"b": [1]}, dtype="Int64")
2927+
result = pd.concat([df_a, df_b], ignore_index=True)
2928+
expected = pd.DataFrame({"a": [-1, None], "b": [None, 1]}, dtype="Int64")
2929+
tm.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)