|
1 | 1 | import importlib
|
2 | 2 | from typing import List, Type # noqa
|
| 3 | +import warnings |
3 | 4 |
|
4 | 5 | from pandas.util._decorators import Appender
|
5 | 6 |
|
@@ -518,11 +519,6 @@ def _get_call_args(data, args, kwargs):
|
518 | 519 | signatures, since `DataFramePlotMethods` accepted `x` and `y`
|
519 | 520 | parameters.
|
520 | 521 | """
|
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 |
| - |
526 | 522 | if isinstance(data, ABCSeries):
|
527 | 523 | arg_def = [
|
528 | 524 | ('kind', 'line'), ('ax', None), ('figsize', None),
|
@@ -550,6 +546,18 @@ def _get_call_args(data, args, kwargs):
|
550 | 546 | 'Series or DataFrame').format(
|
551 | 547 | type(data).__name__))
|
552 | 548 |
|
| 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 | + |
553 | 561 | pos_args = {name: value for value, (name, _) in zip(args, arg_def)}
|
554 | 562 | kwargs = dict(arg_def, **pos_args, **kwargs)
|
555 | 563 |
|
|
0 commit comments