Skip to content

Commit b5f11fd

Browse files
Adding warning for positional arguments in Series.plot (without testing)
1 parent fe4b19e commit b5f11fd

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

pandas/plotting/_core.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import importlib
22
from typing import List, Type # noqa
3+
import warnings
34

45
from pandas.util._decorators import Appender
56

@@ -518,11 +519,6 @@ def _get_call_args(data, args, kwargs):
518519
signatures, since `DataFramePlotMethods` accepted `x` and `y`
519520
parameters.
520521
"""
521-
if args and isinstance(data, ABCSeries):
522-
# TODO raise warning here, positional arguments shouldn't be
523-
# used anymore, so we can add x, y and kind to the signature
524-
pass
525-
526522
if isinstance(data, ABCSeries):
527523
arg_def = [
528524
('kind', 'line'), ('ax', None), ('figsize', None),
@@ -550,6 +546,18 @@ def _get_call_args(data, args, kwargs):
550546
'Series or DataFrame').format(
551547
type(data).__name__))
552548

549+
if args and isinstance(data, ABCSeries):
550+
msg = ('`Series.plot()` should not be called with positional '
551+
'arguments, only keyword arguments. The order of '
552+
'positional arguments will change in the future. '
553+
'Use `Series.plot({})` instead of `Series.plot({})`.')
554+
positional_args = str(args)[1:-1]
555+
keyword_args = ', '.join('{}={!r}'.format(name, value)
556+
for (name, default), value
557+
in zip(arg_def, args))
558+
warnings.warn(msg.format(keyword_args, positional_args),
559+
FutureWarning, stacklevel=3)
560+
553561
pos_args = {name: value for value, (name, _) in zip(args, arg_def)}
554562
kwargs = dict(arg_def, **pos_args, **kwargs)
555563

0 commit comments

Comments
 (0)