Converting numpy solution into dask (numpy indexing doesn’t work in dask)
Chunk random_days_panel instead of historical_data and use da.map_blocks: def dask_way(sim_count, sim_days, hist_days): # shared historical data # on a cluster you’d load this on each worker, e.g. from a NPZ file historical_data = np.random.normal(111.51, 10, size=hist_days) random_days_panel = da.random.randint( 1, hist_days, size=(1, 1, sim_count, sim_days) ) future_panel = da.map_blocks( lambda chunk: historical_data[chunk], random_days_panel, dtype=float ) … Read more