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 oka
Eventhough, you might still have a problem with precision depending on the base values.
You can still use round
to specify the amount of decimal you wish to have.
df = pd.DataFrame([(.2132481, .399452), (.012311, .13267), (.613216, .01233), (.213211, .181235)])
df.values.round(3).tolist()
>> [[0.213, 0.399], [0.012, 0.133], [0.613, 0.012], [0.213, 0.181]]
The 3
in .round(3)
goes for three decimals.