title: Bootstrap Samples of a Dask Dataframe
body: <p>I have a large data frame with all binary variables (a sparse matrix that was converted into pandas so that I can later convert to Dask). The dimensions are 398,888 x 52,034.</p>
  <p>I am trying to create a much larger data frame that consists of 10,000 different bootstrap samples from the original data frame. Each sample is the same size as the original data. The final data frame will also have a column that keeps track of which bootstrap sample that row is from.</p>
  <p>Here is my code:</p>
  <pre><code># sample df
  df_pd = pd.DataFrame(np.array([[0, 0, 0, 0], [1, 0, 0, 0], [0, 1, 0, 1]]),
                     columns=['a', 'b', 'c'])
  # convert into Dask dataframe
  df_dd = dd.from_pandas(df_pd, npartitions=4)
  
  B = 2  # eventually 10,000
  big_df = dd.from_pandas(pd.DataFrame([]), npartitions = 1000)
  for i in range(B+1):
      data = df_dd.sample(frac = 1, replace = True, random_state=i)
      data[&quot;sample&quot;] = i
      big_df.append(data)
  </code></pre>
  <p>The data frame produced by the loop is empty, but I cannot figure out why. To be more specific, if I look at <code>big_df.head()</code> I get, <code>UserWarning: Insufficient elements for 'head'. 5 elements requested, only 0 elements available. Try passing larger 'npartitions' to 'head'.</code> If I try <code>print(big_df)</code>, I get, <code>ValueError: No objects to concatenate</code>.</p>
  <p>My guess is there is at least a problem with this line, <code>big_df = dd.from_pandas(pd.DataFrame([]), npartitions = 1000)</code>, but I have no idea.</p>
  <p>Let me know if I need to clarify anything. I am somewhat new to Python and even newer to Dask, so even small tips or feedback that don't fully answer the question would be greatly appreciated. Thanks!</p>