在pandas中加载mongodb中的数据
#导入相应的包
import pymongo
import pandas as pd
from pandas import Series,DataFrame
#连接数据库
#mongo_url = f'mongodb://{username}:{password}@%{host}:{port}/{db}'
client = pymongo.MongoClient('localhost',27017)
#加载库
ganji = client['ganji']
#加载collection
info = ganji['info']
#加载数据
data = DataFrame(list(info.find()))
#删除不想要的字段
data_new = data.T.drop(['_id','url','title'])
print(data_new)