# Init
import time
import pandas as pd
import numpy as np
from dask.distributed import Client
client = Client()
# Publish data
dataset_name = 'my_dataset'
df_my_dataset = pd.DataFrame(np.ones((2,3)), dtype=np.float32)
client.publish_dataset(df_my_dataset, name=dataset_name)
在那里:
In [13]: client.list_datasets()
Out[13]: ('my_dataset',)
为 dask 创建提交函数。在这里,我想按名称访问已发布的数据集:
# submit function
def get_gate1_rows(df_from_submit):
return df_from_submit.mean()
# return df.mean() + my_dataset.mean() #### <<<<<<< How to do this?
最后提交:
# Submit code
df_zeros = np.zeros((2,3), dtype=np.float32)
future = client.submit(get_gate1_rows, df_zeros)
time.sleep(2)
result = future.result()
这会产生 - 但应该是0.5
:
In [41]: result
Out[41]: 0.0
那么我怎样才能published dataset
从dask工作中访问呢?