我有一个由同事开发的Mongo数据库,当我上载到Pandas数据框时,该数据库不会显示一半字段,而另一部分则显示为字符串。
尽管我对蒙哥并不太了解,但我还是尝试浏览蒙哥的结构。 我还尝试使用collection.find()来显示错误。
这是我的python(PyMongo和Pandas)代码:
client = MongoClient("(String of Mongo DB")
db = client.Project
collection = db.users
df = pd.DataFrame(list(collection.find()))
df.to_excel(writer, sheet_name='tester')
writer.save()
print(df)
这是MongoDB的结构:
var transactions = mongoose.Schema({
date: Date,
type: String,
description: String,
debit: String,
credit: String,
currency: String,
balance: String
})
var userSchema = mongoose.Schema({
local: {
email: String,
name: String,
profilePic: String,
username: String,
password: String,
birthDate: Date,
img: String,
firstTime: Boolean,
dateCreation: Date,
gender: String,
maritalStatus: String,
country: String,
cardP: {
current: String,
},
accounts: [{
id: Number,
name: String,
bankName: String,
img: String,
number: Number,
profile: String,
iban: String,
balance: Number,
transactions: [transactions]
}],
profiles: [{
id: String,
text: String
}],
alerts: [{
id: Number,
title: String,
text: String
}]
},
});
我希望有几个列的数据框会出现,但这出现了:
__v: 0
_id: 5cf7f08a6721e016203af46c
local:{'accounts': [{'_id': ObjectId('5d00c3fd7b7b631b982d64be'), 'id': 123567, 'name': 'Bank', 'img': ' (and a lot more of fields)