Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions pandas/plotting/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,10 @@ def _get_call_args(backend_name: str, data: Series | DataFrame, args, kwargs):
if args and isinstance(data, ABCSeries):
positional_args = str(args)[1:-1]
keyword_args = ", ".join(
[f"{name}={value!r}" for (name, _), value in zip(arg_def, args)]
[
f"{name}={value!r}"
for (name, _), value in zip(arg_def, args, strict=False)
]
)
msg = (
"`Series.plot()` should not be called with positional "
Expand All @@ -973,7 +976,9 @@ def _get_call_args(backend_name: str, data: Series | DataFrame, args, kwargs):
)
raise TypeError(msg)

pos_args = {name: value for (name, _), value in zip(arg_def, args)}
pos_args = {
name: value for (name, _), value in zip(arg_def, args, strict=False)
}
if backend_name == "pandas.plotting._matplotlib":
kwargs = dict(arg_def, **pos_args, **kwargs)
else:
Expand Down
10 changes: 5 additions & 5 deletions pandas/plotting/_matplotlib/boxplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,9 @@ def _grouped_plot_by_column(

ax_values = []

for ax, col in zip(flatten_axes(axes), columns):
for ax, col in zip(flatten_axes(axes), columns, strict=False):
gp_col = grouped[col]
keys, values = zip(*gp_col)
keys, values = zip(*gp_col, strict=True)
re_plotf = plotf(keys, values, ax, xlabel=xlabel, ylabel=ylabel, **kwargs)
ax.set_title(col)
ax_values.append(re_plotf)
Expand Down Expand Up @@ -380,7 +380,7 @@ def _get_colors():
# taken from the colors dict parameter
# "boxes" value placed in position 0, "whiskers" in 1, etc.
valid_keys = ["boxes", "whiskers", "medians", "caps"]
key_to_index = dict(zip(valid_keys, range(4)))
key_to_index = dict(zip(valid_keys, range(4), strict=True))
for key, value in colors.items():
if key in valid_keys:
result[key_to_index[key]] = value
Expand Down Expand Up @@ -530,7 +530,7 @@ def boxplot_frame_groupby(
layout=layout,
)
data = {}
for (key, group), ax in zip(grouped, flatten_axes(axes)):
for (key, group), ax in zip(grouped, flatten_axes(axes), strict=False):
d = group.boxplot(
ax=ax, column=column, fontsize=fontsize, rot=rot, grid=grid, **kwds
)
Expand All @@ -539,7 +539,7 @@ def boxplot_frame_groupby(
ret = pd.Series(data)
maybe_adjust_figure(fig, bottom=0.15, top=0.9, left=0.1, right=0.9, wspace=0.2)
else:
keys, frames = zip(*grouped)
keys, frames = zip(*grouped, strict=True)
df = pd.concat(frames, keys=keys, axis=1)

# GH 16748, DataFrameGroupby fails when subplots=False and `column` argument
Expand Down
13 changes: 8 additions & 5 deletions pandas/plotting/_matplotlib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ def _adorn_subplots(self, fig: Figure) -> None:
f"number of columns = {self.nseries}"
)

for ax, title in zip(self.axes, self.title):
for ax, title in zip(self.axes, self.title, strict=False):
ax.set_title(title)
else:
fig.suptitle(self.title)
Expand Down Expand Up @@ -1216,7 +1216,7 @@ def _get_errorbars(
) -> dict[str, Any]:
errors = {}

for kw, flag in zip(["xerr", "yerr"], [xerr, yerr]):
for kw, flag in zip(["xerr", "yerr"], [xerr, yerr], strict=True):
if flag:
err = self.errors[kw]
# user provided label-matched dataframe of errors
Expand Down Expand Up @@ -1457,7 +1457,7 @@ def _get_color_mapping(self, c_values: Series) -> dict[str, np.ndarray]:
cmap = mpl.colormaps.get_cmap(self.colormap)
colors = cmap(np.linspace(0, 1, n_colors)) # RGB tuples

return dict(zip(unique, colors))
return dict(zip(unique, colors, strict=True))

def _get_norm_and_cmap(self, c_values, color_by_categorical: bool):
c = self.c
Expand Down Expand Up @@ -2178,7 +2178,10 @@ def blank_labeler(label, value):
# Blank out labels for values of 0 so they don't overlap
# with nonzero wedges
if labels is not None:
blabels = [blank_labeler(left, value) for left, value in zip(labels, y)]
blabels = [
blank_labeler(left, value)
for left, value in zip(labels, y, strict=True)
]
else:
blabels = None
results = ax.pie(y, labels=blabels, **kwds)
Expand All @@ -2197,7 +2200,7 @@ def blank_labeler(label, value):

# leglabels is used for legend labels
leglabels = labels if labels is not None else idx
for _patch, _leglabel in zip(patches, leglabels):
for _patch, _leglabel in zip(patches, leglabels, strict=True):
self._append_legend_handles_labels(_patch, _leglabel)

def _post_plot_logic(self, ax: Axes, data) -> None:
Expand Down
4 changes: 2 additions & 2 deletions pandas/plotting/_matplotlib/hist.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def _grouped_plot(
naxes=naxes, figsize=figsize, sharex=sharex, sharey=sharey, ax=ax, layout=layout
)

for ax, (key, group) in zip(flatten_axes(axes), grouped):
for ax, (key, group) in zip(flatten_axes(axes), grouped, strict=False):
if numeric_only and isinstance(group, ABCDataFrame):
group = group._get_numeric_data()
plotf(group, ax, **kwargs)
Expand Down Expand Up @@ -557,7 +557,7 @@ def hist_frame(
)
can_set_label = "label" not in kwds

for ax, col in zip(flatten_axes(axes), data.columns):
for ax, col in zip(flatten_axes(axes), data.columns, strict=False):
if legend and can_set_label:
kwds["label"] = col
ax.hist(data[col].dropna().values, bins=bins, **kwds)
Expand Down
6 changes: 3 additions & 3 deletions pandas/plotting/_matplotlib/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def normalize(series):

ax.add_patch(mpl.patches.Circle((0.0, 0.0), radius=1.0, facecolor="none"))

for xy, name in zip(s, df.columns):
for xy, name in zip(s, df.columns, strict=True):
ax.add_patch(mpl.patches.Circle(xy, radius=0.025, facecolor="gray"))

if xy[0] < 0.0 and xy[1] < 0.0:
Expand Down Expand Up @@ -266,7 +266,7 @@ def f(t):
color_values = get_standard_colors(
num_colors=len(classes), colormap=colormap, color_type="random", color=color
)
colors = dict(zip(classes, color_values))
colors = dict(zip(classes, color_values, strict=False))
if ax is None:
ax = plt.gca()
ax.set_xlim(-np.pi, np.pi)
Expand Down Expand Up @@ -399,7 +399,7 @@ def parallel_coordinates(
if sort_labels:
classes = sorted(classes)
color_values = sorted(color_values)
colors = dict(zip(classes, color_values))
colors = dict(zip(classes, color_values, strict=True))

for i in range(n):
y = df.iloc[i].values
Expand Down
5 changes: 0 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -494,11 +494,6 @@ exclude = [
"pandas/io/sql.py" = ["B905"]
"pandas/io/stata.py" = ["B905"]
"pandas/io/xml.py" = ["B905"]
"pandas/plotting/_core.py" = ["B905"]
"pandas/plotting/_matplotlib/boxplot.py" = ["B905"]
"pandas/plotting/_matplotlib/core.py" = ["B905"]
"pandas/plotting/_matplotlib/hist.py" = ["B905"]
"pandas/plotting/_matplotlib/misc.py" = ["B905"]
"pandas/_testing/asserters.py" = ["B905"]
"pandas/_testing/_warnings.py" = ["B905"]
"pandas/tests/apply/test_series_apply.py" = ["B905"]
Expand Down
Loading