Skip to content

Commit d093840

Browse files
phoflnoatamir
authored andcommitted
REGR: read_csv and nullable dtypes fails if dtype is specified (pandas-dev#49147)
1 parent 353436c commit d093840

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

pandas/_libs/parsers.pyx

+3
Original file line numberDiff line numberDiff line change
@@ -1414,6 +1414,9 @@ def _maybe_upcast(arr, use_nullable_dtypes: bool = False):
14141414
-------
14151415
The casted array.
14161416
"""
1417+
if is_extension_array_dtype(arr.dtype):
1418+
return arr
1419+
14171420
na_value = na_values[arr.dtype]
14181421

14191422
if issubclass(arr.dtype.type, np.integer):

pandas/tests/io/parser/dtypes/test_dtypes_basic.py

+11
Original file line numberDiff line numberDiff line change
@@ -466,3 +466,14 @@ def test_use_nullabla_dtypes_string(all_parsers, storage):
466466
}
467467
)
468468
tm.assert_frame_equal(result, expected)
469+
470+
471+
def test_use_nullable_dtypes_ea_dtype_specified(all_parsers):
472+
# GH#491496
473+
data = """a,b
474+
1,2
475+
"""
476+
parser = all_parsers
477+
result = parser.read_csv(StringIO(data), dtype="Int64", use_nullable_dtypes=True)
478+
expected = DataFrame({"a": [1], "b": 2}, dtype="Int64")
479+
tm.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)