我写了一个for循环,该循环花费太多时间。我希望在多个处理器上运行它。但是,我不确定如何实现这一目标。有几个任务困扰着我。像打印数字f迭代已经完成,追加结果等。请帮助我知道什么是可能的解决方案。这样我的代码可以更快地执行。
count = 1
total_count = len(screen_2_column_names)
for t in screen_2_column_names:
#start_time_2 = time.time()
print("--- Processing %s of %s ---" % (str(count), str(total_count)))
#print("--- Word Being Processed %s ---" % (t))
column_name.append(t)
date.append(date_Value)
topic_train_1column_18_06_final['check'] = topic_train_1column_18_06_final.Snippet.apply(lambda x : count_documents(t, x))
temp_df = topic_train_1column_18_06_final.loc[(topic_train_1column_18_06_final['check'] == True), "Total_SRPVS"].astype('int64')
document_SRPVS.append(temp_df.sum())
count = count + 1
#print("--- %s seconds to process %s ---\n" % (round((time.time() - start_time_2),0), t))
print("--- Second Screen Data in %s minutes ---" % (round((time.time() - start_time_6)/60,0)))
df = pd.concat([pd.Series(date), pd.Series(column_name), pd.Series(document_SRPVS)], axis=1)
感谢您的帮助。