<p>The solution you likely want is here,</p>

<pre><code>pd.set_eng_float_format(accuracy=x, use_eng_prefix=True)
</code></pre>

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

<hr>

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

<p>Best idea</p>

<pre><code>gwas_rs_id['logged'] = np.log(gwas_rs_id.marker)
</code></pre>

<p>First idea,</p>

<pre><code>import decimal as D
.... 
gwas_rs_id['marker'] = gwas_rs_id['marker'].astype(D.decimal)
</code></pre>

<p>Last attempt,</p>

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

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

CC BY-SA 4.0
2019-07-11T19:59:05.177Z
2019-07-12T11:51:49.350Z
2019-07-12T11:51:49.350Z
M__
<p>I am working with a specific GWAS.  If I were to run this on the command line</p>

<pre><code>grep &lt;rs_id_of_interest&gt; GWAS.txt
</code></pre>

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

<p>However, if I were to do the same but in pandas, with the following code, </p>

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

<p>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?</p>

<p>Thanks!</p>

CC BY-SA 4.0
2019-07-11T17:55:35.230Z
You need convert the dataframe column to a float, I'll post the code if you get stuck
M__
CC BY-SA 4.0
2019-07-11T18:22:41.540Z
I tried setting the column to np.float64, but it did not work.
Andrew Hamel
<python><phylogenetics><phylogeny><gwas>
Pandas automatically rounds GWAS P-value
# Pandas automatically rounds GWAS P-value

(Asked by: username_0 on 2019-07-11)

I am working with a specific GWAS.  If I were to run this on the command line
grep  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?
Thanks!

**Tags:** python, phylogenetics, phylogeny, gwas
> **Comments:**
> **username_1**: You need convert the dataframe column to a float, I'll post the code if you get stuck  
> **username_0**: I tried setting the column to np.float64, but it did not work.  

---

## 1 answers

### Answer by username_1 on 2019-07-11. Score: 2 | Accepted answer

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.


---

