Skip to content
Advertisement

How to create a crosstab table of percentages bucketed into deciles in mysql

I’ve got the following table:

I can bucket those percentages into deciles and create a crosstab table in Pandas like this:

I’m trying to find a way to do this entirely in MySQL, without saving the table to a Pandas DataFrame first. Is that possible?

Thanks!!

Advertisement

Answer

Here’s the final code. To exactly match the Pandas output, I needed to force Precision values of 0 up slightly to put those values into the first bucket of >0-10

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement