Question: increasing floating point precision in pandas
0
gravatar for QVINTVS_FABIVS_MAXIMVS
4.2 years ago by
USA SoCal
QVINTVS_FABIVS_MAXIMVS2.3k wrote:

 

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

 

 

floating point pandas python • 4.3k views
ADD COMMENTlink modified 4.2 years ago by Philipp Bayer6.5k • written 4.2 years ago by QVINTVS_FABIVS_MAXIMVS2.3k

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 REPLYlink written 4.2 years ago by Devon Ryan92k

They sure do

ADD REPLYlink written 4.2 years ago by QVINTVS_FABIVS_MAXIMVS2.3k
2
gravatar for Philipp Bayer
4.2 years ago by
Philipp Bayer6.5k
Australia/Perth/UWA
Philipp Bayer6.5k wrote:

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 COMMENTlink written 4.2 years ago by Philipp Bayer6.5k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1895 users visited in the last hour