Skip to content

Commit eb0acac

Browse files
committed
Fix __getitem__ indexing to iloc indexing
Added test
1 parent 0b8fa9d commit eb0acac

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

pandas/core/style.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def _translate(self):
237237
cs = [DATA_CLASS, "row%s" % r, "col%s" % c]
238238
cs.extend(cell_context.get("data", {}).get(r, {}).get(c, []))
239239
row_es.append({"type": "td",
240-
"value": self.data.iloc[r][c],
240+
"value": self.data.iloc[r, c],
241241
"class": " ".join(cs),
242242
"id": "_".join(cs[1:])})
243243
props = []

pandas/tests/test_style.py

+6
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,12 @@ def test_multiindex_name(self):
164164

165165
self.assertEqual(result['head'], expected)
166166

167+
def test_numeric_columns(self):
168+
# https://github.com/pydata/pandas/issues/12125
169+
# smoke test for _translate
170+
df = pd.DataFrame({0: [1, 2, 3]})
171+
df.style._translate()
172+
167173
def test_apply_axis(self):
168174
df = pd.DataFrame({'A': [0, 0], 'B': [1, 1]})
169175
f = lambda x: ['val: %s' % x.max() for v in x]

0 commit comments

Comments
 (0)