我有一个 CSV,我需要在 python 中创建一列随机的唯一 MongoDB id。
这是我的 csv 文件:
import pandas as pd
df = pd.read_csv('file.csv', sep=';')
print(df)
Zone
Zone_1
Zone_2
我目前正在使用这行代码来生成一个唯一的ObjectId- UPDATE
import bson
x = bson.objectid.ObjectId()
df['objectids'] = x
print(df)
Zone; objectids
Zone_1; 5bce2e42f6738f20cc12518d
Zone_2; 5bce2e42f6738f20cc12518d
如何让每行的 ObjectId 都是唯一的?
相关分类