@@ -128,6 +128,8 @@ def _kind(self) -> str:
128
128
def orientation (self ) -> str | None :
129
129
return None
130
130
131
+ data : DataFrame
132
+
131
133
def __init__ (
132
134
self ,
133
135
data ,
@@ -270,6 +272,7 @@ def __init__(
270
272
self .kwds = kwds
271
273
272
274
self ._validate_color_args ()
275
+ self .data = self ._ensure_frame (self .data )
273
276
274
277
@final
275
278
@staticmethod
@@ -619,9 +622,7 @@ def _convert_to_ndarray(data):
619
622
return data
620
623
621
624
@final
622
- def _compute_plot_data (self ):
623
- data = self .data
624
-
625
+ def _ensure_frame (self , data ) -> DataFrame :
625
626
if isinstance (data , ABCSeries ):
626
627
label = self .label
627
628
if label is None and data .name is None :
@@ -634,6 +635,11 @@ def _compute_plot_data(self):
634
635
elif self ._kind in ("hist" , "box" ):
635
636
cols = self .columns if self .by is None else self .columns + self .by
636
637
data = data .loc [:, cols ]
638
+ return data
639
+
640
+ @final
641
+ def _compute_plot_data (self ):
642
+ data = self .data
637
643
638
644
# GH15079 reconstruct data if by is defined
639
645
if self .by is not None :
@@ -887,6 +893,7 @@ def _get_xticks(self):
887
893
index = self .data .index
888
894
is_datetype = index .inferred_type in ("datetime" , "date" , "datetime64" , "time" )
889
895
896
+ # TODO: be stricter about x?
890
897
x : list [int ] | np .ndarray
891
898
if self .use_index :
892
899
if isinstance (index , ABCPeriodIndex ):
@@ -1468,7 +1475,10 @@ def _make_plot(self, fig: Figure) -> None:
1468
1475
# "Callable[[Any, Any, Any, Any, Any, Any, KwArg(Any)], Any]", variable has
1469
1476
# type "Callable[[Any, Any, Any, Any, KwArg(Any)], Any]")
1470
1477
plotf = self ._plot # type: ignore[assignment]
1471
- it = self ._iter_data (data = self .data )
1478
+ # error: Incompatible types in assignment (expression has type
1479
+ # "Iterator[tuple[Hashable, ndarray[Any, Any]]]", variable has
1480
+ # type "Iterable[tuple[Hashable, Series]]")
1481
+ it = self ._iter_data (data = self .data ) # type: ignore[assignment]
1472
1482
1473
1483
stacking_id = self ._get_stacking_id ()
1474
1484
is_errorbar = com .any_not_none (* self .errors .values ())
@@ -1481,7 +1491,9 @@ def _make_plot(self, fig: Figure) -> None:
1481
1491
colors ,
1482
1492
kwds ,
1483
1493
i ,
1484
- label , # pyright: ignore[reportGeneralTypeIssues]
1494
+ # error: Argument 4 to "_apply_style_colors" of "MPLPlot" has
1495
+ # incompatible type "Hashable"; expected "str"
1496
+ label , # type: ignore[arg-type] # pyright: ignore[reportGeneralTypeIssues]
1485
1497
)
1486
1498
1487
1499
errors = self ._get_errorbars (label = label , index = i )
0 commit comments