首页 > 解决方案 > 如何使用python在具有匹配_id的MongoDB表中插入一个新字段?

问题描述

我的 mongodb 中有一个表(table1),如下所示。例如,我只给出了 2 个条目,但计数可以是千......

table1:

_id Name Class
1  'xyz'  '12th'
2  'abc'  '11th' and so on....

我的笔记本(python)中有另一个表(DataFrame),如下所示

table2:

_id zip_code
1   123
2   121
3   145 and so on....

现在我要求通过 python 程序通过 mongodb table1 进行更新,如下所示。

_id Name Class   zip_code
1  'xyz'  '12th' 123
2  'abc'  '11th' 121 

所以基本上我想运行我的 python 代码以将zip_codecol 从table2插入到table1mongodb 与匹配_id

标签: pythonmongodb

解决方案


推荐阅读