Skip to content

Commit 5e30ba6

Browse files
committed
fix failed cicd
1 parent 84d2d79 commit 5e30ba6

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

pandas/plotting/_matplotlib/boxplot.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,10 @@ def _make_plot(self, fig: Figure) -> None:
212212

213213
# When `by` is assigned, the ticklabels will become unique grouped
214214
# values, instead of label which is used as subtitle in this case.
215-
# error: "Index" has no attribute "levels"; maybe "nlevels"?
216-
levels = self.data.columns.levels # type: ignore[attr-defined]
217-
ticklabels = [pprint_thing(col) for col in self.data.columns.get_level_values(0)] #
215+
ticklabels = [
216+
pprint_thing(col)
217+
for col in self.data.columns.get_level_values(0)
218+
]
218219
else:
219220
ticklabels = [pprint_thing(label)]
220221

pandas/tests/plotting/test_boxplot_method.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -410,13 +410,18 @@ def test_boxplot_group_no_xlabel_ylabel(self, vert, request):
410410
assert target_label == pprint_thing(["group"])
411411

412412
@pytest.mark.filterwarnings("ignore:set_ticklabels:UserWarning")
413-
def test_boxplot_group_xlabel_ylabel(self, vert):
414-
df = DataFrame({'value': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
415-
'label': ['c', 'c', 'c', 'c', 'b', 'b', 'b', 'b', 'a', 'a']})
416-
df.label = Categorical(df.label, categories=['c', 'b', 'a'], ordered=True)
413+
def test_boxplot_group_ordered_ticklabel(self, vert):
414+
df = DataFrame(
415+
{
416+
"value": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
417+
"label": ["c", "c", "c", "c", "b", "b", "b", "b", "a", "a"],
418+
}
419+
)
420+
df.label = Categorical(df.label, categories=["c", "b", "a"], ordered=True)
417421
ax = df.boxplot(by="label")
418422
xticklabels = ax.get_xticklabels()
419-
assert [x.get_text() for x in xticklabels] == ['c', 'b', 'a']
423+
assert [x.get_text() for x in xticklabels] == ["c", "b", "a"]
424+
420425

421426
class TestDataFrameGroupByPlots:
422427
def test_boxplot_legacy1(self, hist_df):

0 commit comments

Comments
 (0)