increasing floating point precision in pandas
1
0
Entering edit mode
9.3 years ago

I have a pandas data frame with mixed types

I would like to increase the floating point precision of the columns with float64 to 500 point precision.

Is there an easy solution using decimal library? I'm having some troubles with the current methods.

from decimal import *
getcontext().prec = 500
df['floating'] = df['floating'].astype(Decimal)

df['phred'] = -10 * np.log10(1-df['floating'])

Error:

AttributeError: 'float' object has no attribute 'log10
python pandas floating-point • 7.6k views
ADD COMMENT
0
Entering edit mode

I hope you've considered whether any of the initial values that you're using even have 500 significant digits.

BTW, this is pretty off-topic.

ADD REPLY
0
Entering edit mode

They sure do

ADD REPLY
2
Entering edit mode
9.3 years ago

This tiny piece here:

np.log10(1-df['floating'])

seems to cause your problems with log10, did you do import numpy as np in your script, and are you sure that you didn't overwrite "np" with some floating point number?

ADD COMMENT

Login before adding your answer.

Traffic: 2394 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6