Skip to content

Commit ca3c9f3

Browse files
Terji Petersentopper-123
Terji Petersen
authored andcommitted
fix use of Index._holds_integer
1 parent ed7ce68 commit ca3c9f3

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

pandas/plotting/_core.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,7 @@ def __call__(self, *args, **kwargs):
957957
# check if we have y as int or list of ints
958958
int_ylist = is_list_like(y) and all(is_integer(c) for c in y)
959959
int_y_arg = is_integer(y) or int_ylist
960-
if int_y_arg and data.columns._should_fallback_to_positional:
960+
if int_y_arg and not data.columns._holds_integer():
961961
y = data_cols[y]
962962

963963
label_kw = kwargs["label"] if "label" in kwargs else False

pandas/plotting/_matplotlib/core.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1137,9 +1137,9 @@ def __init__(self, data, x, y, **kwargs) -> None:
11371137
MPLPlot.__init__(self, data, **kwargs)
11381138
if x is None or y is None:
11391139
raise ValueError(self._kind + " requires an x and y column")
1140-
if is_integer(x) and self.data.columns._should_fallback_to_positional:
1140+
if is_integer(x) and not self.data.columns._holds_integer():
11411141
x = self.data.columns[x]
1142-
if is_integer(y) and self.data.columns._should_fallback_to_positional:
1142+
if is_integer(y) and not self.data.columns._holds_integer():
11431143
y = self.data.columns[y]
11441144

11451145
# Scatter plot allows to plot objects data
@@ -1196,7 +1196,7 @@ def __init__(self, data, x, y, s=None, c=None, **kwargs) -> None:
11961196
elif is_hashable(s) and s in data.columns:
11971197
s = data[s]
11981198
super().__init__(data, x, y, s=s, **kwargs)
1199-
if is_integer(c) and self.data.columns._holds_integer():
1199+
if is_integer(c) and not self.data.columns._holds_integer():
12001200
c = self.data.columns[c]
12011201
self.c = c
12021202

@@ -1291,7 +1291,7 @@ def _kind(self) -> Literal["hexbin"]:
12911291

12921292
def __init__(self, data, x, y, C=None, **kwargs) -> None:
12931293
super().__init__(data, x, y, **kwargs)
1294-
if is_integer(C) and self.data.columns._holds_integer():
1294+
if is_integer(C) and not self.data.columns._holds_integer():
12951295
C = self.data.columns[C]
12961296
self.C = C
12971297

0 commit comments

Comments
 (0)