@@ -736,26 +736,23 @@ def _get_call_args(backend_name, data, args, kwargs):
736
736
]
737
737
else :
738
738
raise TypeError (
739
- (
740
- "Called plot accessor for type {}, expected Series or DataFrame"
741
- ).format (type (data ).__name__ )
739
+ f"Called plot accessor for type { type (data ).__name__ } , "
740
+ "expected Series or DataFrame"
742
741
)
743
742
744
743
if args and isinstance (data , ABCSeries ):
744
+ positional_args = str (args )[1 :- 1 ]
745
+ keyword_args = ", " .join (
746
+ f"{ name } ={ value !r} " for (name , default ), value in zip (arg_def , args )
747
+ )
745
748
msg = (
746
749
"`Series.plot()` should not be called with positional "
747
750
"arguments, only keyword arguments. The order of "
748
751
"positional arguments will change in the future. "
749
- "Use `Series.plot({})` instead of `Series.plot({})`."
750
- )
751
- positional_args = str (args )[1 :- 1 ]
752
- keyword_args = ", " .join (
753
- "{}={!r}" .format (name , value )
754
- for (name , default ), value in zip (arg_def , args )
755
- )
756
- warnings .warn (
757
- msg .format (keyword_args , positional_args ), FutureWarning , stacklevel = 3
752
+ f"Use `Series.plot({ keyword_args } )` instead of "
753
+ f"`Series.plot({ positional_args } )`."
758
754
)
755
+ warnings .warn (msg , FutureWarning , stacklevel = 3 )
759
756
760
757
pos_args = {name : value for value , (name , _ ) in zip (args , arg_def )}
761
758
if backend_name == "pandas.plotting._matplotlib" :
@@ -782,7 +779,7 @@ def __call__(self, *args, **kwargs):
782
779
return plot_backend .plot (self ._parent , x = x , y = y , kind = kind , ** kwargs )
783
780
784
781
if kind not in self ._all_kinds :
785
- raise ValueError ("{ } is not a valid plot kind". format ( kind ) )
782
+ raise ValueError (f" { kind } is not a valid plot kind" )
786
783
787
784
# The original data structured can be transformed before passed to the
788
785
# backend. For example, for DataFrame is common to set the index as the
@@ -796,14 +793,13 @@ def __call__(self, *args, **kwargs):
796
793
if isinstance (data , ABCDataFrame ):
797
794
return plot_backend .plot (data , x = x , y = y , kind = kind , ** kwargs )
798
795
else :
799
- raise ValueError (
800
- ("plot kind {} can only be used for data frames" ).format (kind )
801
- )
796
+ raise ValueError (f"plot kind { kind } can only be used for data frames" )
802
797
elif kind in self ._series_kinds :
803
798
if isinstance (data , ABCDataFrame ):
804
799
if y is None and kwargs .get ("subplots" ) is False :
805
- msg = "{} requires either y column or 'subplots=True'"
806
- raise ValueError (msg .format (kind ))
800
+ raise ValueError (
801
+ f"{ kind } requires either y column or 'subplots=True'"
802
+ )
807
803
elif y is not None :
808
804
if is_integer (y ) and not data .columns .holds_integer ():
809
805
y = data .columns [y ]
@@ -1639,12 +1635,11 @@ def _find_backend(backend: str):
1639
1635
_backends [backend ] = module
1640
1636
return module
1641
1637
1642
- msg = (
1643
- "Could not find plotting backend '{name }'. Ensure that you've installed the "
1644
- " package providing the '{name }' entrypoint, or that the package has a"
1638
+ raise ValueError (
1639
+ f "Could not find plotting backend '{ backend } '. Ensure that you've installed "
1640
+ f"the package providing the '{ backend } ' entrypoint, or that the package has a "
1645
1641
"top-level `.plot` method."
1646
1642
)
1647
- raise ValueError (msg .format (name = backend ))
1648
1643
1649
1644
1650
1645
def _get_plot_backend (backend = None ):
0 commit comments