I am working with a specific GWAS. If I were to run this on the command line

grep <rs_id_of_interest> GWAS.txt

I would see the GWAS p-value to be on the order of 10^-200. Very tiny p-value.

However, if I were to do the same but in pandas, with the following code,

gwas = pd.read_csv(GWAS_file,sep='\t')
gwas_rs_id = gwas.loc[gwas['marker'] == 'rs_id'].copy()

and then print gwas_rs_id, it shows the gwas p-value to be 0.0. Is there a way to read the file and not have it automatically round the tiny tiny p-values?


  • $\begingroup$ You need convert the dataframe column to a float, I'll post the code if you get stuck $\endgroup$
    – M__
    Commented Jul 11, 2019 at 17:55
  • $\begingroup$ I tried setting the column to np.float64, but it did not work. $\endgroup$ Commented Jul 11, 2019 at 18:22

1 Answer 1


The solution you likely want is here,

pd.set_eng_float_format(accuracy=x, use_eng_prefix=True)

x = whatever is required The function set_eng_float_format has been moved around a bit and is now a top level function

You might be dealing with maximum likelihood, so convert to log likelihood -200 that sort of thing

Best idea

gwas_rs_id['logged'] = np.log(gwas_rs_id.marker)

First idea,

import decimal as D
gwas_rs_id['marker'] = gwas_rs_id['marker'].astype(D.decimal)

Last attempt,

pd.set_option('display.precision', x) # x whatever dp you need, this might work in combination with a log likelihood

Try a gwas_rs_id.dtype() check whether you're using float32, float64 or still in object. It should convert to scientific notion (E values) automatically.


Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.