title: how to write mongodb query in python for db.collection.group()
body: <p>I am working on a  MongoDB query</p>
  
  <pre><code>db.BH.group({
  "key": {
      "AccountId": true,
  },
  "initial": {
      "count": 0
  },
  "reduce": function(obj, prev) {
      if (true != null) if (true instanceof Array) prev.count += true.length;
      else prev.count++;
  },
  "cond":     
      {"$or":[{"Url":{"$regex":"(google)"}},{"Url":{"$regex":"(facebook)"}}]} 
  }); 
  </code></pre>
  
  <p>The query is working fine in MongoDB Shell(Robomongo).</p>
  
  <p>I have written the same query for python.</p>
  
  <pre><code>db.BH.group({
  "key": {
      "AccountId": True,
  },
  "initial": {
      "count": 0
  },
  "reduce": "function(obj, prev) {"
      "if (true != null) if (true instanceof Array) prev.count += true.length;"
      "else prev.count++;"
  "}",
  "cond": {"$or":[{"Url":{"$regex":"(google)"}},{"Url":{"$regex":"(facebook)"}}]} 
  }) 
  </code></pre>
  
  <p>But error is coming for the query.</p>
  
  <pre><code>TypeError: group() takes at least 5 arguments (2 given)
  </code></pre>
  
  <p>I tried to solve the error from the method given in the below website(URL)</p>
  
  <p><a href="http://blog.pythonisito.com/2012/05/aggregation-in-mongodb-part-1.html" rel="nofollow">http://blog.pythonisito.com/2012/05/aggregation-in-mongodb-part-1.html</a></p>
  
  <p>But the same error persists.</p>