一、将pandas DataFrame 存入数据库MongoDB
import json
import pymongo
import pandas as pd
client = pymongo.MongoClient("localhost",27017)
test = client['test']
user = test['juser']
juser = pd.read_csv("C:/dat/data/juser.csv")
juser = juser.drop_duplicates("userId")
records = json.loads(juser.T.to_json()).values()
user.insert_many(records)
二、MongoDB删除数据库:db.dropDatabase()
三、按时期筛选,统计数据:http://www.mamicode.com/info-detail-1822406.html
网友评论