Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions pandas/_libs/parsers.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1414,6 +1414,9 @@ def _maybe_upcast(arr, use_nullable_dtypes: bool = False):
-------
The casted array.
"""
if is_extension_array_dtype(arr.dtype):
return arr

na_value = na_values[arr.dtype]

if issubclass(arr.dtype.type, np.integer):
Expand Down
11 changes: 11 additions & 0 deletions pandas/tests/io/parser/dtypes/test_dtypes_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,3 +466,14 @@ def test_use_nullabla_dtypes_string(all_parsers, storage):
}
)
tm.assert_frame_equal(result, expected)


def test_use_nullable_dtypes_ea_dtype_specified(all_parsers):
# GH#491496
data = """a,b
1,2
"""
parser = all_parsers
result = parser.read_csv(StringIO(data), dtype="Int64", use_nullable_dtypes=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have tests for dtype="int64", use_nullable_dtypes=True?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test_use_nullabla_dtypes_and_dtype Same file

expected = DataFrame({"a": [1], "b": 2}, dtype="Int64")
tm.assert_frame_equal(result, expected)