mongodb如何存numpy数组[mongodb教程]
1、对于一维numpy数组,可以使用列表:
# serialize 1D array xrecord['feature1'] = x.tolist()
# deserialize 1D array x
x = np.fromiter( record['feature1'] )
2、对于多维数组,你需要使用pickle和pymongo.binary.Binary:
# serialize 2D array yrecord['feature2'] = pymongo.binary.Binary( pickle.dumps( y, protocol=2) ) )
# deserialize 2D array y
y = pickle.loads( record['feature2'] )
以上是 mongodb如何存numpy数组[mongodb教程] 的全部内容, 来源链接: utcz.com/z/528378.html