0

Consider the following data file:

! cat datax
1
1.000
2.000   3.000
3.000   4.000
5.000   6.000

the lines:

f=open('datax', 'r') 
d=np.genfromtxt(f, dtype=None, missing_values=0,usecols=(0))
f.close()

succeed but the lines:

f=open('datax', 'r') 
d=np.genfromtxt(f, dtype=None, missing_values=0,usecols=(0,1))
f.close()

fail. I get the error:

ValueError: Some errors were detected !
   Line #1 (got 1 columns instead of 2)
   Line #2 (got 1 columns instead of 2)

This is because the first two data points of the second column are missing. Special treatment of this case with first missing values is not an option. How do I read the data while ignoring the missing values?

wander95
  • 1,298
  • 1
  • 15
  • 22
  • See [this for possible help](https://stackoverflow.com/questions/46481997/how-to-use-np-genfromtxt-and-fill-in-missing-columns). Basically, `pandas` can handle this more easily than `numpy`... – Gerges Oct 13 '17 at 17:47
  • What do you mean by 'ignoring the missing values'? Skipping those rows entirely, or filling the missing values with some sort of `nan`? – hpaulj Oct 13 '17 at 18:04
  • @hpa filling with missing values – wander95 Oct 13 '17 at 18:11

0 Answers0