[Numpy-discussion] bug in genfromtxt with missing values?
Skipper Seabold
jsseabold at gmail.com
Tue Jan 25 11:56:55 EST 2011
On Tue, Jan 25, 2011 at 11:17 AM, Pierre GM <pgmdevlist at gmail.com> wrote:
>
> On Jan 24, 2011, at 11:47 PM, Skipper Seabold wrote:
>
>> Am I misreading the docs or missing something? Consider the following
>> adapted from here:
>> http://docs.scipy.org/doc/numpy/user/basics.io.genfromtxt.html
>>
>> 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.
>>
>
> It's probably a bug . Mind opening a ticket ? I'll try to care of it when I can.
> Thx in advance
> P.
http://projects.scipy.org/numpy/ticket/1722
Forgot to use the code formatting, and it doesn't look like I can edit.
Thanks,
Skipper
More information about the NumPy-Discussion
mailing list