plotly.js icon indicating copy to clipboard operation
plotly.js copied to clipboard

Plotly Transform Aggretation: median calculation appears wrong

Open mwills opened this issue 6 years ago • 2 comments

I have an application that can show the data in box format or aggregate into a scatter. I noticed that some groups were showing different 'median' values.

here is a simple example using the numbers of 6, 28, 33, 37, 49 which is resulting in a median of 37...

See the Pen Plotly.js Transforms median error?

mwills avatar Jun 30 '20 00:06 mwills

@mwills thanks very much for the report and a minimal example. It appears there is a sorting problem when numbers have different digits! And if I add 100 to that list I get the correct answer | demo.

archmoj avatar Jun 30 '20 12:06 archmoj

Heh we’re probably falling into the trap of assuming the default sort function is numeric, but it’s actually string-based. I never did understand that choice...

alexcjohnson avatar Jun 30 '20 13:06 alexcjohnson