私はdictの値のフラットなリスト(「キー」と呼ばれる)を返す関数を並列化したいが、最終結果を得る方法は分からない。私が試してみました:toParallelファンクションキーとしてハッシュタグと(キーがintです)キーのリストと辞書を返すべきPythonマルチプロセッシング - dictを返す
def toParallel(ht, token):
keys = []
words = token[token['hashtag'] == ht]['word']
for w in words:
keys.append(checkString(w))
y = {ht:keys}
num_cores = multiprocessing.cpu_count()
pool = multiprocessing.Pool(num_cores)
token = pd.read_csv('/path', sep=",", header = None, encoding='utf-8')
token.columns = ['word', 'hashtag', 'count']
hashtag = pd.DataFrame(token.groupby(by='hashtag', as_index=False).count()['hashtag'])
result = pd.DataFrame(index = hashtag['hashtag'], columns = range(0, 21))
result = result.fillna(0)
final_result = []
final_result = [pool.apply_async(toParallel, args=(ht,token,)) for ht in hashtag['hashtag']]
。私はfinal_result印刷しようとする場合でも、私は
が、私はそれを行うことができますどのように0x10c4fa950
でmultiprocessing.pool.ApplyResultオブジェクトのメソッドApplyResult.getを拘束得ますか?