8000 genfromtxt does not handle single value missing_values (Trac #1722) · Issue #2317 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

genfromtxt does not handle single value missing_values (Trac #1722) #2317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
numpy-gitbot opened this issue Oct 19, 2012 · 2 comments
Closed

Comments

@numpy-gitbot
Copy link

Original ticket http://projects.scipy.org/numpy/ticket/1722 on 2011-01-25 by @jseabold, assigned to unknown.

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.]])

@Thav
Copy link
Thav commented Feb 28, 2013

This behavior also affects filling_values alone. The default settings for missing_values locates them in all columns, but using a single value filling_values, like filling_values=0 does not work unless the 0 is made a string filling_values="0"
http://stackoverflow.com/questions/15144352/numpy-genfromtxt-using-filling-missing-correctly#comment21322447_15144352

@charris
Copy link
Member
charris commented Feb 19, 2014

Still present in 1.9-devel.

@charris charris modified the milestone: NumPy 2.0 Feb 19, 2014
@seberg seberg closed this as 8719 completed in 9c76897 Aug 16, 2014
seberg added a commit that referenced this issue Aug 16, 2014
BUG: io: genfromtxt did not handle filling_values=0 correctly. Closes gh-2317.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
0