title: Python Dask map_partitions
body: <p>Probably a continuation of this <a href="https://stackoverflow.com/questions/47125665/simple-dask-map-partitions-example">question</a>, working from the dask docs examples for map_partitions. </p>
  
  <pre><code>import dask.dataframe as dd
  df = pd.DataFrame({'x': [1, 2, 3, 4, 5],     'y': [1., 2., 3., 4., 5.]})
  ddf = dd.from_pandas(df, npartitions=2)
  
  from random import randint
  
  def myadd(df):
      new_value = df.x + randint(1,4)
      return new_value
  
  res = ddf.map_partitions(lambda df: df.assign(z=myadd)).compute()
  res
  </code></pre>
  
  <p>In the above code, randint is only being called once, not once per row as I would expect. How come? </p>
  
  <p>Output: </p>
  
  <p>X  Y  Z</p>
  
  <p>1  1  4</p>
  
  <p>2  2  5</p>
  
  <p>3  3  6</p>
  
  <p>4  4  7</p>
  
  <p>5  5  8</p>