title: In a file some variable names are written that needs to be replaced with newly generated random values using python?
body: <p>I am wanting to replace variables in a CSV file with a randomly generated variable for each of the variables.</p>
  <p>For instance, changing 'not available' to either 'male' or 'female'</p>
  <p>Sample:</p>
  <pre><code>Number    Sex
  0         Female
  1         Male
  2         Not Available
  3         Male
  4         Not Available
  </code></pre>
  <p>after random change:</p>
  <pre><code>Number    Sex
  0         Female
  1         Male
  2         Female
  3         Male
  4         Male
  
  </code></pre>
  <pre><code>import pandas as pd
  import random
  
  def RandomSex():
      return random.choice(['Male','Female'])
  
  
  df = pd.read_csv(r'data.csv')
  df2 = df.loc[: , 'Sex']
  print(df2)
  df.loc[(df.Sex == 'Not Available'),'Gender'] = RandomSex()
  print(df2)
  </code></pre>
  <p>But this is changing all of the 'Not Available' to either all 'Male' or all 'Female'</p>