我有两个在计算中相互依赖的数据帧,我想通过一次compute()调用获得两个数据帧的结果。代码可以总结如下:
import dask
import dask.dataframe
import dask.distributed
import pandas as pd
df = dask.dataframe.from_pandas(
pd.DataFrame({
"group": ['a', 'b', 'a', 'b', 'a', 'b', 'b'],
"var_1": [0, 1, 2, 1, 2, 1, 0],
"var_2": [1, 1, 2, 1, 2, 1, 0]}), npartitions=2)
with dask.distributed.Client() as client:
for i in range(10):
df_agg = foo(df)
df = bar(df, df_agg)
print(df.compute())
print(df_agg.compute()) # -> I would like to have only one .compute() call and get the results of both dataframes (df and df_agg) …Run Code Online (Sandbox Code Playgroud) 我非常喜欢这个^^。我在一个视图中使用了一个名为修饰符_dico的函数,该函数位于一个名为fonctions.py的文件中。Modify_dico的前两行如下:
def modifier_dico(tweet,nom_dico, dico_cat):
exec('dico= {}')
Run Code Online (Sandbox Code Playgroud)
我的看法如下:
def classer_tweet(request):
modifier_dico(tweet.text,"dico_status.txt", {})
Run Code Online (Sandbox Code Playgroud)
当我尝试访问该视图时,进入name 'dico' is not definedDjango的调试页面。
但是当我查看回溯中的modifier_dico的局部变量时,我得到了变量dico的值为{}
好像exec()没有按我预期的那样工作。