Skip to content

Commit 45c8237

Browse files
committed
Merge remote-tracking branch 'upstream/master' into lucaionescu-mcmali
2 parents 8b7ac7d + 7595313 commit 45c8237

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

pandas/core/generic.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ def _get_index_resolvers(self) -> Dict[str, ABCSeries]:
461461
for axis_name in self._AXIS_ORDERS:
462462
d.update(self._get_axis_resolvers(axis_name))
463463

464-
return {clean_column_name(k): v for k, v in d.items() if k is not int}
464+
return {clean_column_name(k): v for k, v in d.items() if not isinstance(k, int)}
465465

466466
def _get_cleaned_column_resolvers(self) -> Dict[str, ABCSeries]:
467467
"""
@@ -476,7 +476,9 @@ def _get_cleaned_column_resolvers(self) -> Dict[str, ABCSeries]:
476476
if isinstance(self, ABCSeries):
477477
return {clean_column_name(self.name): self}
478478

479-
return {clean_column_name(k): v for k, v in self.items() if k is not int}
479+
return {
480+
clean_column_name(k): v for k, v in self.items() if not isinstance(k, int)
481+
}
480482

481483
@property
482484
def _info_axis(self):

pandas/tests/frame/test_query_eval.py

+1
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,7 @@ def df(self):
10761076
"that's": [9, 1, 8],
10771077
"☺": [8, 7, 6],
10781078
"foo#bar": [2, 4, 5],
1079+
1: [5, 7, 9],
10791080
}
10801081
)
10811082

pandas/tests/plotting/test_frame.py

+28
Original file line numberDiff line numberDiff line change
@@ -3271,6 +3271,34 @@ def test_plot_no_numeric_data(self):
32713271
with pytest.raises(TypeError):
32723272
df.plot()
32733273

3274+
def test_missing_markers_legend(self):
3275+
# 14958
3276+
df = pd.DataFrame(np.random.randn(8, 3), columns=["A", "B", "C"])
3277+
ax = df.plot(y=["A"], marker="x", linestyle="solid")
3278+
df.plot(y=["B"], marker="o", linestyle="dotted", ax=ax)
3279+
df.plot(y=["C"], marker="<", linestyle="dotted", ax=ax)
3280+
3281+
self._check_legend_labels(ax, labels=["A", "B", "C"])
3282+
self._check_legend_marker(ax, expected_markers=["x", "o", "<"])
3283+
3284+
def test_missing_markers_legend_using_style(self):
3285+
# 14563
3286+
df = pd.DataFrame(
3287+
{
3288+
"A": [1, 2, 3, 4, 5, 6],
3289+
"B": [2, 4, 1, 3, 2, 4],
3290+
"C": [3, 3, 2, 6, 4, 2],
3291+
"X": [1, 2, 3, 4, 5, 6],
3292+
}
3293+
)
3294+
3295+
fig, ax = self.plt.subplots()
3296+
for kind in "ABC":
3297+
df.plot("X", kind, label=kind, ax=ax, style=".")
3298+
3299+
self._check_legend_labels(ax, labels=["A", "B", "C"])
3300+
self._check_legend_marker(ax, expected_markers=[".", ".", "."])
3301+
32743302

32753303
def _generate_4_axes_via_gridspec():
32763304
import matplotlib.pyplot as plt

0 commit comments

Comments
 (0)