title: Python & Pandas: Set a random value to a column, based on conditions
body: <p>My dataframe look like this:</p>
  
  <p><a href="https://i.stack.imgur.com/12JTW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/12JTW.png" alt="enter image description here"></a></p>
  
  <p>I want to set the <code>speed</code> into a uniform random value between 0,1, if the <code>dir</code> is 999 and if 'speed' is 0.</p>
  
  <p>I do this: </p>
  
  <pre><code>df.loc[(df['dir'] == 999)&amp;(df['speed'] == 0), 'speed'] = np.random.uniform(0,1)
  </code></pre>
  
  <p>But it turns out every speed is set into same value:</p>
  
  <pre><code>date
  19800111    0.453046
  19800111    0.453046
  19800111    0.453046
  19800111    0.453046
  19800111    0.453046
  19800111    0.453046
  19800111    0.453046
  19800111    0.453046
  </code></pre>
  
  <p>I'm not sure what I did is wrong? How can I fix this?</p>