interstellar - 9 months ago 48

Python Question

I'm having some trouble using the mannwhitneyu test provided by scipy. I think my problem is with importing. Here is my script:

`SNPs=[]`

Nonsense=[]

with open("final_positions_SNP_removed_duplicates_truepos_truetrans_normalized.txt") as fd:

fd.readline()

for line in fd:

SNPs.append(line.split()[8])

with open("final_positions_nonsense_truepos_truetrans_normalized.txt") as fd:

fd.readline()

for line in fd:

Nonsense.append(line.split()[8])

from scipy import stats

from scipy.stats import mannwhitneyu

u_value, p_value = scipy.stats.mannwhitneyu(SNPs, Nonsense)

I keep getting an error that states:

`NameError: name 'scipy' is not defined`

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

Answer Source

```
from scipy.stats import mannwhitneyu
u_value, p_value = scipy.stats.mannwhitneyu(SNPs, Nonsense)
```

You have imported `mannwhitneyu`

, so you should use

```
u_value, p_value = mannwhitneyu(SNPs, Nonsense)
```

The reason you are getting `NameError: name 'scipy' is not defined`

is that you did not import `scipy`

, you only imported modules from `scipy`

. to import `scipy`

itself you would have to do:

```
import scipy
```

Recommended from our users: **Dynamic Network Monitoring from WhatsUp Gold from IPSwitch**. ** Free Download**