1

I have a dataframe as so:

and the datatypes are as follows:

enter image description here

When I convert the dataframe to a numpy array, the result looks like this: enter image description here

Why does this happen? if I convert the dtypes of all the columns to the same dtype by :

df = df.astype('float64')

then the result looks fine, but why does this happen?

Albin
  • 61
  • 7

1 Answers1

0

Reason if float precision problem, possible solution should be Decimal if precision is important:

from decimal import Decimal

df = df.astype('float64').applymap(Decimal)
jezrael
  • 822,522
  • 95
  • 1,334
  • 1,252