[NumPy-Tickets] [NumPy] #1722: genfromtxt does not handle single value missing_values

NumPy Trac numpy-tickets@scipy....
Tue Jan 25 10:53:59 CST 2011


#1722: genfromtxt does not handle single value missing_values
----------------------------------------+-----------------------------------
 Reporter:  jseabold                    |       Owner:  somebody
     Type:  defect                      |      Status:  new     
 Priority:  normal                      |   Milestone:  2.0.0   
Component:  numpy.lib                   |     Version:  devel   
 Keywords:  genfromtxt, missing_values  |  
----------------------------------------+-----------------------------------
 from StringIO import StringIO
 import numpy as np

 data = "1, 2, 3\n4, ,5"

 np.genfromtxt(StringIO(data), delimiter=",", names="a,b,c",
 missing_values=" ", filling_values=0)
 array([(1.0, 2.0, 3.0), (4.0, nan, 5.0)],
      dtype=[('a', '<f8'), ('b', '<f8'), ('c', '<f8')])

 np.genfromtxt(StringIO(data), delimiter=",", names="a,b,c",
 missing_values={'b':" "}, filling_values={'b' : 0})
 array([(1.0, 2.0, 3.0), (4.0, 0.0, 5.0)],
      dtype=[('a', '<f8'), ('b', '<f8'), ('c', '<f8')])

 Unless I use the dict for missing_values, it doesn't fill them in.
 Without named columns

 np.genfromtxt(StringIO(data), delimiter=",", missing_values=" ",
 filling_values=0)
 array([[  1.,   2.,   3.],
       [  4.,  nan,   5.]])

 np.genfromtxt(StringIO(data), delimiter=",", missing_values={1 :" "},
 filling_values={1 :0})
 array([[ 1.,  2.,  3.],
       [ 4.,  0.,  5.]])

-- 
Ticket URL: <http://projects.scipy.org/numpy/ticket/1722>
NumPy <http://projects.scipy.org/numpy>
My example project


More information about the NumPy-Tickets mailing list