Skip to content
Advertisement

Why do I lose numerical precision when extracting element from list in python?

I have a pandas dataframe that looks like this:

JavaScript

I am trying to extract the 1st element from the Series of lists using this code:

JavaScript

and I get this result:

JavaScript

Why do I lose precision and what can I do to keep it?

Advertisement

Answer

By default, pandas displays floating-point values with 6 digits of precision.

You can control the precision with pandas’ set_option e.g.

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