So I'm trying to convert a float DataFrame to a list (of list) by using row.values.tolist() (row was read from a CSV file). It does the job pretty okay though for a few values the precision is being affected, so, for instance, instead of 32.337 it's outputting 32.336999999999996.
Since tolist() yields a list of list and I need to work with lists, I decided to switch to list(row.values.flatten()), but it introduces precision issues for almost any value in the list, which just makes it worst.
I found a discussion on Github about this issue, from almost 3 years ago, but I can't find anything else up to date and I have no idea how to overcome this.
I tried using pd.set_option('display.precision',4) since for most values I need a maximum of four significant digits, but this isn't working either (assuming I'm using it right).
Is there any workaround for this?
As Padraic alluded, you are not modifying the correct option with
display.precision. Instead, try: