Skip to content

Commit 4037aa8

Browse files
committed
make dtype to be ignored in constructors if data is Series or DataFrame
The note in the docs wasn't sufficient: the dtype kwarg was ignored in certain cases. Set it to None if creating Series from another Series and the same for DataFrames. See GH #59060.
1 parent 0d12b44 commit 4037aa8

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

pandas/core/frame.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,7 @@ def __init__(
705705
if isinstance(data, DataFrame):
706706
data = data._mgr
707707
allow_mgr = True
708+
dtype = None
708709
if not copy:
709710
# if not copying data, ensure to still return a shallow copy
710711
# to avoid the result sharing the same Manager

pandas/core/series.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ def __init__(
445445
"compound dtype. Use DataFrame instead."
446446
)
447447
elif isinstance(data, Series):
448+
dtype = None
448449
if index is None:
449450
index = data.index
450451
data = data._mgr.copy(deep=False)

0 commit comments

Comments
 (0)