Skip to content

PERF: Styler #43285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 30, 2021
Merged

PERF: Styler #43285

merged 1 commit into from
Aug 30, 2021

Conversation

jbrockmendel
Copy link
Member

from asv_bench.benchmarks.io.style import *
self = Render()
self.setup(36, 12)

%timeit self.setup(36, 12); self.time_apply_render(36, 12)
29.2 ms ± 1.2 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)  # <- master
9.98 ms ± 706 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)  # <- PR

cc @attack68

@jbrockmendel jbrockmendel added Performance Memory or execution speed performance Styler conditional formatting using DataFrame.style labels Aug 29, 2021
@attack68
Copy link
Contributor

nice. good spot. lgtm. tests seem unrelated. there might be one or two other places this pattern might be better too.

@attack68 attack68 mentioned this pull request Aug 29, 2021
@@ -1023,7 +1023,8 @@ def _update_ctx(self, attrs: DataFrame) -> None:
)

for cn in attrs.columns:
for rn, c in attrs[[cn]].itertuples():
ser = attrs[cn]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ser = attrs[cn]
j = self.columns.get_loc(cn)
ser = attrs[cn]

(remove repeated j lookup below)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can actually go further and just do for j, cn in enumerate(attrs.columns):, but will ask you to do that in #43287

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't becuase of subset, we are cross matching objects:
i.e.

self.columns ~ ["a", "b", "c", "d"]
attrs.columns ~ ["b", "d"]
=> j ~ [1, 3]  # not enumerate

@jreback jreback added this to the 1.4 milestone Aug 30, 2021
@jreback jreback merged commit 3a83e11 into pandas-dev:master Aug 30, 2021
@jreback
Copy link
Contributor

jreback commented Aug 30, 2021

thanks @jbrockmendel

@jbrockmendel jbrockmendel deleted the perf-styler branch August 30, 2021 14:42
feefladder pushed a commit to feefladder/pandas that referenced this pull request Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Performance Memory or execution speed performance Styler conditional formatting using DataFrame.style
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants