连接mongodb 单字段去重
import pandas as pd
import pymongo
client = pymongo.MongoClient(host="192.168.9.108", port=27017)
# client = pymongo.MongoClient('mongodb://jevy:112244@localhost:27017/')
db = client['FinanceModule']
collection =db['in_out_exist'] # 数据库的名称
res=collection.distinct("名称")
多字段去重
res=collection.aggregate([{
'$group':{
'_id': {'pt': "$规格", 'pn': "$名称"},
}
}])
参考链接: