Skip to content

ENH: omit CSSStyle rules for hidden table elements (#43619) #43673

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 5 commits into from
Sep 22, 2021

Conversation

rendner
Copy link
Contributor

@rendner rendner commented Sep 20, 2021

I couldn't run all tests, because of the following problem, which isn't related to my changes:

pandas/tests/io/test_orc.py terminate called after throwing an instance of 'orc::TimezoneError'
  what():  Can't open /etc/localtime
Fatal Python error: Aborted

Copy link
Contributor

@attack68 attack68 left a comment

Choose a reason for hiding this comment

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

looks good but comments

@attack68
Copy link
Contributor

You don't have to, but might also like to try and solve the same issue for the index or column headers, that might get CSS for ids if applymap_index(lambda v: "color: blue;") is used..

@attack68 attack68 added Styler conditional formatting using DataFrame.style Performance Memory or execution speed performance labels Sep 21, 2021
@rendner rendner changed the title ENH: omit CSSStyle rules for hidden table cells (#43619) ENH: omit CSSStyle rules for hidden table elements (#43619) Sep 21, 2021
@rendner
Copy link
Contributor Author

rendner commented Sep 21, 2021

You don't have to, but might also like to try and solve the same issue for the index or column headers, that might get CSS for ids if applymap_index(lambda v: "color: blue;") is used..

I also implemented it for column and index headers.

@rendner rendner requested a review from attack68 September 21, 2021 11:39
@jreback jreback added this to the 1.4 milestone Sep 21, 2021
@jreback
Copy link
Contributor

jreback commented Sep 21, 2021

do we have an asv for this? can you show the perf change (and add asv if we don't have).

@attack68
Copy link
Contributor

do we have an asv for this? can you show the perf change (and add asv if we don't have).
I will have a look at this and make a suggestion for a more general asv that can also test this.
Note that this can also improve browser performance as well, not just pandas performance.

Copy link
Contributor

@attack68 attack68 left a comment

Choose a reason for hiding this comment

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

lgtm. i will take a look at the asvs, but even if the performance improvement is marginal it makes better HTML anyway.

@jreback
Copy link
Contributor

jreback commented Sep 21, 2021

lgtm. i will take a look at the asvs, but even if the performance improvement is marginal it makes better HTML anyway.

sure, just covering bases

@attack68
Copy link
Contributor

attack68 commented Sep 21, 2021

@rendner you can use the code in #43687 to see the rendering performance enhancement. I expect minimal, but the performance in HTML might be better for large dataframes.

To execute it see the contributing to pandas page running the performance test suite: https://pandas.pydata.org/docs/development/contributing_codebase.html

  >$ cd asv_bench
  >asv_bench$ asv continuous -f 1.1 upstream/master HEAD -b style.Render -E virtualenv

@rendner
Copy link
Contributor Author

rendner commented Sep 22, 2021

@attack68 Thank you.

asv continuous -f 1.1 upstream/master HEAD -b style.Render -E virtualenv

The command gave me the following error Unknown commit upstream/master.
So I used this one asv continuous -f 1.1 011c016f6 HEAD -b style.Render -E virtualenv.
011c016f6 is the first commit before my changes, which you can verify here: https://github.com/rendner/pandas/commits/enh-43619

Here are the results:

       before           after         ratio
     [011c016f]       [fe9e44b9]
     <master>         <enh-43619>
-      21.1±0.2ms       19.0±0.3ms     0.90  io.style.Render.time_apply_format_hide_render(36, 12)
-      75.5±0.8ms       61.6±0.6ms     0.82  io.style.Render.time_apply_format_hide_render(24, 120)
-      40.7±0.4ms       33.0±0.7ms     0.81  io.style.Render.time_apply_format_hide_render(12, 120)
-       110±0.5ms       88.1±0.4ms     0.80  io.style.Render.time_apply_format_hide_render(36, 120)

SOME BENCHMARKS HAVE CHANGED SIGNIFICANTLY.
PERFORMANCE INCREASED.

I guess the performance for hidden cells could be further improved by moving the data_element_visible check at the start of the for loop. And if not visible continue with the next cell. But I'm unsure how much we would gain.

@attack68
Copy link
Contributor

I guess the performance for hidden cells could be further improved by moving the data_element_visible check at the start of the for loop. And if not visible continue with the next cell. But I'm unsure how much we would gain.

This is good, don't need anything else. Im surprised it gets this much improvement but the asv does specifically hide almost all elements. @jreback happy to merge?

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

lgtm

@attack68 attack68 merged commit 8b12cb6 into pandas-dev:master Sep 22, 2021
@attack68
Copy link
Contributor

thanks @rendner

@rendner rendner deleted the enh-43619 branch September 23, 2021 14:42
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.

ENH: omit CSS rules for excluded html-table elements
3 participants