Skip to content

Conversation

@attack68
Copy link
Contributor

@attack68 attack68 commented Mar 14, 2021

This PR is a minor fix/improvement to a recent PR which deprecated set_na_rep and set_precision. #40134

For a dataframe with 100,000 floats the current Styler default formatter will make 100,000 get_option lookups for the pandas precision.

Doing this calculation once prevents all these lookups and saves just over 10% render time for larger tables.

rows                       THIS PR   
------ -------------------------
 cols       12          120     
====== ============ ============
  12    11.8±0.2ms   40.8±0.8ms 
  24    22.5±0.3ms    69.2±2ms  
  36    32.3±0.6ms    96.9±1ms  
====== ============ ============
rows                        MASTER         
------ -------------------------
 cols       12          120     
====== ============ ============
  12    12.9±0.4ms    43.4±1ms  
  24    22.3±0.1ms   75.2±0.7ms 
  36    32.3±0.3ms   105±0.5ms  
====== ============ ============

@simonjayhawkins simonjayhawkins added Performance Memory or execution speed performance Styler conditional formatting using DataFrame.style labels Mar 14, 2021
Copy link
Member

@rhshadrach rhshadrach left a comment

Choose a reason for hiding this comment

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

lgtm, just a question on the whatsnew

@jreback jreback added this to the 1.3 milestone Mar 14, 2021
@jreback jreback merged commit cd5f15d into pandas-dev:master Mar 14, 2021
@jreback
Copy link
Contributor

jreback commented Mar 14, 2021

thanks @attack68

@attack68 attack68 deleted the perf_default_formatter branch March 15, 2021 14:27
JulianWgs pushed a commit to JulianWgs/pandas that referenced this pull request Jul 3, 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.

4 participants