title: Getting scipy to accept missing data
body: <p>I need to include missing data in the scipy pearsonr function. The problem is that if I read it from a file with e.g. 'NA' then I cannot convert it to float so that numpy will accept it. If I read it with numpy then the flexible array type with the 'NA' values cannot be used with 'dropna' or similar. How can I get scipy to accept missing data? I have read about data masks but I don't understand how to use it in the code.</p>
  
  <p>Thanks,</p>
  
  <pre><code>#!/usr/bin/env python
  import sys
  import scipy.stats as sp
  import numpy as np
  
  f1=open(sys.argv[1],'r') 
  
  f2=open(sys.argv[2],'r') 
  
  g=open(sys.argv[3],'w')
  
  f1.readline()
  
  otus=[]
  metanames=[]
  result={}
  
  for i in f1:
  
      k1=i.split("\t")
      k1[-1]=k1[-1].rstrip("\n")
      otu=k1[0]
  
      f2.seek(0)
  
      result[otu]=[]
      f2.readline()
  
      for j in f2:
  
          k2=j.split("\t")
          k2[-1]=k2[-1].rstrip("\n")
  
          if k2[0] not in metanames:
              metanames.append(k2[0])
  
          x=np.asarray(k1[1:])
          y=np.asarray(k2[1:])
  
          corr = sp.pearsonr(x, y)
  
          result[otu].append(str(corr))
  
  g.write("\t"+"\t".join(str(p) for p in metanames)+"\n")
  
  for i in result.keys():
  
      g.write(i+"\t"+"\t".join(str(p) for p in result[i][0])+"\n")
  </code></pre>
  
  <p>TypeError: cannot perform reduce with flexible type</p>