[Python] How do I show small numbers with scientific notation in Pandas Dataframe Python?

Discussão em 'Python' iniciado por Stack, Março 15, 2025.

  1. Stack

    Stack Membro Participativo

    I'm working with a dataframe that on one column has numbers of different order of magnitude, the biggest is 0.315 and the smallest is 0.xxe-28. My problem is that when I display the pd dataframe I get this:

    [​IMG]

    Small numbers are rounded to 0.0

    I'd like to show every number in scientific notation like: 3.15e-1, 6.55e-28, and so on. How can I do that? Thank you!

    EDIT: I found that pd.set_option('display.float_format', '{:.2E}'.format) almost does the trick. The problem is that now all the columns are in that format:

    [​IMG]

    Is it possible to use set_option to specify a format just for one column?

    Continue reading...

Compartilhe esta Página