Using numpy to build an array of all combinations of two arrays
Cartesian product function by Stackoverflow user, pv.
See Answer here.
Using numpy to build an array of all combinations of two arrays
Cartesian product function by Stackoverflow user, pv.
See Answer here.
| //equivalent of MySQL SELECT COUNT(*) AS cnt, fieldName FROM someTable GROUP BY fieldName; | |
| db.someCollection.aggregate([{"$group" : {_id:"$fieldName", cnt:{$sum:1}}}]); | |
| //as above but ordered by the count descending | |
| //eg: SELECT COUNT(*) AS cnt, fieldName FROM someTable GROUP BY fieldName ORDER BY cnt DESC; | |
| db.someCollection.aggregate([{"$group" : {_id:"$fieldName", cnt:{$sum:1}}}, {$sort:{'cnt':-1}}]); | |
| db.order.aggregate([{ $group: { _id: "$seller_email", total_order: { "$sum": 1 }, | |
| seller_address_1 : { $first: '$seller_address_1' }, | |
| seller_country : { $first: '$seller_country' }, |