title: replace blanks in numpy array
body: <p>The third column in my numpy array is Age. In this column about 75% of the entries are valid and 25% are blank. Column 2 is Gender and using some manipulation I have calculated the average age of the men in my dataset to be 30. The average age of women in my dataset is 28.</p>
  
  <p>I want to replace all blank Age values for men to be 30 and all blank age values for women to be 28.</p>
  
  <p>However I can't seem to do this. Anyone have a suggestion or know what I am doing wrong?</p>
  
  <p>Here is my code:</p>
  
  <pre><code># my entire data set is stored in a numpy array defined as x
  
  ismale = x[::,1]=='male'
  maleAgeBlank = x[ismale][::,2]==''
  x[ismale][maleAgeBlank][::,2] = 30 
  </code></pre>
  
  <p>For whatever reason when I'm done with the above code, I type <code>x</code> to display the data set and the blanks still exist even though I set them to 30. Note that I cannot do <code>x[maleAgeBlank]</code> because that list will include some female data points since the female data points are not yet excluded.</p>
  
  <p>Is there any way to get what I want? For some reason, if I do <code>x[ismale][::,1] = 1</code> (setting the column with 'male' equal to 1), that works, but <code>x[ismale][maleAgeBlank][::,2] = 30</code> does not work.</p>
  
  <p>sample of array:</p>
  
  <pre><code>#output from typing x
  array([['3', '1', '22', ..., '0', '7.25', '2'],
     ['1', '0', '38', ..., '0', '71.2833', '0'],
     ['3', '0', '26', ..., '0', '7.925', '2'],
     ..., 
     ['3', '0', '', ..., '2', '23.45', '2'],
     ['1', '1', '26', ..., '0', '30', '0'],
     ['3', '1', '32', ..., '0', '7.75', '1']], 
    dtype='&lt;U82')
  
  #output from typing x[0]
  
  array(['3', '1', '22', '1', '0', '7.25', '2'], 
    dtype='&lt;U82')
  </code></pre>
  
  <p>Note that I have changed column 2 to be 0 for female and 1 for male already in the above output</p>