Skip to content

Commit 6aeefe5

Browse files
Terji PetersenTerji Petersen
Terji Petersen
authored and
Terji Petersen
committed
fix use of Index._holds_integer
1 parent 7ed0731 commit 6aeefe5

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
@@ -956,7 +956,7 @@ def __call__(self, *args, **kwargs):
956956
# check if we have y as int or list of ints
957957
int_ylist = is_list_like(y) and all(is_integer(c) for c in y)
958958
int_y_arg = is_integer(y) or int_ylist
959-
if int_y_arg and data.columns._should_fallback_to_positional:
959+
if int_y_arg and not data.columns._holds_integer():
960960
y = data_cols[y]
961961

962962
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
@@ -1135,9 +1135,9 @@ def __init__(self, data, x, y, **kwargs) -> None:
11351135
MPLPlot.__init__(self, data, **kwargs)
11361136
if x is None or y is None:
11371137
raise ValueError(self._kind + " requires an x and y column")
1138-
if is_integer(x) and self.data.columns._should_fallback_to_positional:
1138+
if is_integer(x) and not self.data.columns._holds_integer():
11391139
x = self.data.columns[x]
1140-
if is_integer(y) and self.data.columns._should_fallback_to_positional:
1140+
if is_integer(y) and not self.data.columns._holds_integer():
11411141
y = self.data.columns[y]
11421142

11431143
# Scatter plot allows to plot objects data
@@ -1194,7 +1194,7 @@ def __init__(self, data, x, y, s=None, c=None, **kwargs) -> None:
11941194
elif is_hashable(s) and s in data.columns:
11951195
s = data[s]
11961196
super().__init__(data, x, y, s=s, **kwargs)
1197-
if is_integer(c) and self.data.columns._holds_integer():
1197+
if is_integer(c) and not self.data.columns._holds_integer():
11981198
c = self.data.columns[c]
11991199
self.c = c
12001200

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

12871287
def __init__(self, data, x, y, C=None, **kwargs) -> None:
12881288
super().__init__(data, x, y, **kwargs)
1289-
if is_integer(C) and self.data.columns._holds_integer():
1289+
if is_integer(C) and not self.data.columns._holds_integer():
12901290
C = self.data.columns[C]
12911291
self.C = C
12921292

0 commit comments

Comments
 (0)