Skip to content

Commit 78bc8d4

Browse files
committed
BUG: add warning when creating Series from Series with dtype keyword
When creating Series from another Series `dtype` keyword is not not used Make warning for users who expect it to have effect. See GH #59060.
1 parent 67a58cd commit 78bc8d4

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pandas/core/series.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,11 @@ def __init__(
451451
data = data.reindex(index)
452452
copy = False
453453
data = data._mgr
454+
if dtype is not None:
455+
warnings.warn(
456+
"dtype keyword is not used for Series created from Series",
457+
stacklevel=2,
458+
)
454459
elif isinstance(data, Mapping):
455460
data, index = self._init_dict(data, index, dtype)
456461
dtype = None

0 commit comments

Comments
 (0)