jupyter以子线程运行耗时函数

# 如果在jupyter中,希望一个耗时过程以子线程方式运行。然后不影响代码编写过程。 方式如下:

def f_cut_20():
    # IV TOPI20变量    ---非常耗时 5min
    train_data = X_train.reset_index(drop=True).fillna(-9999).copy()
    train_data.insert(0, 'target', y_train.values)
    df_res1_iv,top20_iv = df_cut5(train_data,groups=20)
    df_res1_iv.to_excel('./result/df_cut20_iv.xlsx',index=False)
    
t2 = threading.Thread(target=f_cut_20)#
t2.setDaemon(True)
t2.start()
# t2.join()
原文地址:https://www.cnblogs.com/andylhc/p/15064414.html