在dask中不支持项目分配的解决方法

时间:2019-10-08 14:13:40

标签: python python-3.x dask dask-distributed

我正在尝试将代码库从numpy数组转换为dask,因为我的numpy数组超出了City Day_of_year avg_price price type Rome 1 400 sold_2018 Rome 2 405 sold_2018 Milan 1 300 sold_2018 Milan 2 305 sold_2018 Rome 1 200 sold_2019 Rome 2 200 sold_2019 Milan 1 205 sold_2019 Milan 2 205 sold_2019 Rome 1 200 prediction_2020 Rome 2 200 prediction_2020 Milan 1 205 prediction_2020 Milan 2 205 prediction_2020 的限制。但是,我知道Memory Error中尚未实现可变数组的功能,所以我得到了
dask arrays
下面的代码是否有解决方法?

NotImplementedError: Item assignment with <class 'tuple'> not supported

我还尝试了快速计算所有其他计算,并使用for i, mask in enumerate(masks): bounds = find_boundaries(mask, mode='inner') X2, Y2 = np.nonzero(bounds) X2 = da.from_array(X2, 'auto') Y2 = da.from_array(Y2, 'auto') xSum = (X2.reshape(-1, 1) - X1.reshape(1, -1)) ** 2 ySum = (Y2.reshape(-1, 1) - Y1.reshape(1, -1)) ** 2 #Failing on below line distMap[:,i] = da.sqrt(xSum + ySum).min(axis=0) break 作为一个numpy数组,但仍然得到了distMap。 欢迎任何解决方法。

1 个答案:

答案 0 :(得分:1)

也许您可以构造许多dask数组,然后使用da.concatenateda.stack将它们合并为一个dask数组?