Skip to content

Added test case to lock in behaviour #48541

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 5 commits into from
Sep 15, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions doc/source/whatsnew/v1.6.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ Sparse
ExtensionArray
^^^^^^^^^^^^^^
- Bug in :meth:`Series.mean` overflowing unnecessarily with nullable integers (:issue:`48378`)
- Loss of dtype information when concatenating EA with empty EA of same type (:issue:`48510`)
-

Styler
Expand Down
11 changes: 11 additions & 0 deletions pandas/tests/extension/test_integer.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,3 +234,14 @@ class TestParsing(base.BaseParsingTests):

class Test2DCompat(base.Dim2CompatTests):
pass


def test_concat_to_empty_ea():
"""`concat` to an empty EA should maintain type EA information."""
df_empty = pd.DataFrame({"a": pd.array([], dtype=pd.Int64Dtype())})

df_new = pd.DataFrame({"a": pd.array([1, 2, 3], dtype=pd.Int64Dtype())})

result = pd.concat([df_empty, df_new])

assert result["a"].dtype == df_empty["a"].dtype == df_new["a"].dtype