Skip to content

Commit f95ec17

Browse files
attack68feefladder
authored andcommitted
PERF: Styler 2 (pandas-dev#43287)
1 parent 07ce2b5 commit f95ec17

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pandas/io/formats/style.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1023,12 +1023,13 @@ def _update_ctx(self, attrs: DataFrame) -> None:
10231023
)
10241024

10251025
for cn in attrs.columns:
1026+
j = self.columns.get_loc(cn)
10261027
ser = attrs[cn]
10271028
for rn, c in ser.items():
10281029
if not c or pd.isna(c):
10291030
continue
10301031
css_list = maybe_convert_css_to_tuples(c)
1031-
i, j = self.index.get_loc(rn), self.columns.get_loc(cn)
1032+
i = self.index.get_loc(rn)
10321033
self.ctx[(i, j)].extend(css_list)
10331034

10341035
def _update_ctx_header(self, attrs: DataFrame, axis: int) -> None:
@@ -1048,7 +1049,8 @@ def _update_ctx_header(self, attrs: DataFrame, axis: int) -> None:
10481049
Identifies whether the ctx object being updated is the index or columns
10491050
"""
10501051
for j in attrs.columns:
1051-
for i, c in attrs[[j]].itertuples():
1052+
ser = attrs[j]
1053+
for i, c in ser.items():
10521054
if not c:
10531055
continue
10541056
css_list = maybe_convert_css_to_tuples(c)

0 commit comments

Comments
 (0)