title: How to get uniform distribution by weighted probability in python in a dataset?
body: <p>I have already seen <a href="https://stackoverflow.com/questions/3679694/a-weighted-version-of-random-choice">this question</a> and I know <code>numpy.random.choice</code>, but my question is slightly different.</p>
  
  <p>Given that, I have a dataset as below:</p>
  
  <pre><code>dict ={"Number of polyps":[10,8,3,1,2,6,13],
          "Right ":[3,2,3,1,0,3,3],
          "Left":[2,2,4,15,6,7,1] }
  
  dt = pd.DataFrame(dict)
  </code></pre>
  
  <p>so, it is:</p>
  
  <pre><code>Number of polyps  Right   Left
              10       3     2
               8       2     2
               3       3     4
               1       1    15
               2       0     6
               6       3     7
              13       3     1
  </code></pre>
  
  <p>I need to refill the <code>Right</code> and <code>Left</code> column by below requirement</p>
  
  <ol>
  <li>Sum of <code>Right</code> and <code>Left</code> is equal to <code>Number of polyps</code></li>
  <li>The values of <code>Right</code> and <code>Left</code> comes from weighted probability of <strong>their current</strong> value</li>
  </ol>
  
  <p>For example, for a given row as below:</p>
  
  <pre><code>Number of polyps  Right   Left
              10       3     2
  </code></pre>
  
  <p>so, for this row it could be as below. Here <code>0.6= 3/(3+2)</code> and <code>0.4= 2/(3+2)</code>:</p>
  
  <pre><code>nr = np.random.choice(["Right","Left"],size=10, replace=True,p=[0.6,0.4])
  rightCount = list.count('Right')
  leftCount = list.count('Left')
  print(rightCount)
  print(leftCount)
  </code></pre>
  
  <p>After updating this row will be:</p>
  
  <pre><code>Number of polyps  Right   Left
              10       3     7
  </code></pre>
  
  <p><strong><em>The problem is, I must do it for all the rows in dataset, but I am not sure how to do it!</em></strong></p>