Skip to content
Advertisement

Format / Suppress Scientific Notation from Pandas Aggregation Results

How can one modify the format for the output from a groupby operation in pandas that produces scientific notation for very large numbers?

I know how to do string formatting in python but I’m at a loss when it comes to applying it here.

JavaScript

This suppresses the scientific notation if I convert to string but now I’m just wondering how to string format and add decimals.

JavaScript

Advertisement

Answer

Granted, the answer I linked in the comments is not very helpful. You can specify your own string converter like so.

JavaScript

I’m not sure if that’s the preferred way to do this, but it works.

Converting numbers to strings purely for aesthetic purposes seems like a bad idea, but if you have a good reason, this is one way:

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