PyMongo替换嵌套文档中的字符串

时间:2019-12-29 21:38:36

标签: python mongodb pymongo

假设我有一个文档:

{
  "_id": {
    "$oid": "5cb3f4a098c73d1625970740"
  },
  "Dimensions": {
    "Dimension_1": "NaN",
    "Dimension_2": 1.5
  },
  "Other Dimensions": {
    "Dimension_1": "NaN",
    "Dimension_2": 1.5,
  }
}

预期输出:

{
  "_id": {
    "$oid": "5cb3f4a098c73d1625970740"
  },
  "Dimensions": {
    "Dimension_1": null,
    "Dimension_2": 1.5
  },
  "Other Dimensions": {
    "Dimension_1": null,
    "Dimension_2": 1.5,
  }
}

如何使用PyMongo将文档中的每个字符串"NaN"切换到null

0 个答案:

没有答案