title: How to use bulk_write to quickly update MongoDB Collection?
body: <p>I want to update my whole DB from a Pandas DF but looping takes ages and I´m not familiar enough with pymongo to get it running. This is what I tried but I keep getting this error when trying to update the DB after changing the data in Pandas. What am I doing wrong?</p>
  <pre><code>'errmsg': &quot;E11000 duplicate key error collection&quot;
  df = df.to_dict('records')
  
  collection.bulk_write([ReplaceOne(
                                   record,
                                   record,
                                   upsert=True
                                   )
                                  for record in df
                         ], ordered=False)
  </code></pre>