0

when I convert a column from string to float I lose decimal places, is there a clear way how to keep decimal places?

dicti = {'1': ['55.230530663425',
  '43.597357785755'],
 '2': ['25.231784186637',
  '93.59759890623'],
 '3': ['75.229467797447',
  '33.597732846763'],
 '4': ['15.228959922301',
  '33.596897400263'],
 '5': ['95.231278845519',
  '23.599502230125']}


df = pd.DataFrame.from_dict(dicti, 'index')
df[0] = df[0].astype(float)
df[1] = df[1].astype(float)
print(df)

           0          1
1  55.230531  43.597358
2  25.231784  93.597599
3  75.229468  33.597733
4  15.228960  33.596897
5  95.231279  23.599502
1
  • 1
    they are kept, just not printed out Commented Jan 19, 2022 at 23:41

1 Answer 1

1

Check out the top answer from

Pandas data precision

to see how to change the display precision if you want to see more decimal places. As has been said, the full precision is stored, just not displayed.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.