[英]Wait for Python to finish before next loop
I've tried a few different methods, even just raw wait(240) but it appears that this sometimes doesnt even given enough time.我尝试了几种不同的方法,甚至只是原始的等待(240),但似乎有时这甚至没有给足够的时间。
However I can not get these 2 lines to return before it loops into the next for.但是,在它循环到下一个 for 之前,我无法让这 2 行返回。
f.summary()
f.get_best(method='sumsquare_error')
import numpy as np
import pandas as pd
import seaborn as sns
from fitter import Fitter#, get_common_distributions, get_distributions
from fitter import get_common_distributions
from fitter import get_distributions
from IPython.display import clear_output
import warnings
import pandas as pd
from pandas.core.common import SettingWithCopyWarning
warnings.simplefilter(action="ignore", category=SettingWithCopyWarning)
import time
import subprocess
dataset = pd.read_csv("econ.csv")
for col in dataset.columns:
try:
print(col)
spac = dataset[col].values
f = Fitter(spac, distributions=get_distributions())
f.fit()
f.summary()
f.get_best(method='sumsquare_error')
print("")
#subprocess.call
#result = col.result
#time.sleep(180)
except:
pass
Yes @crunker99, you are correct, the notebook does appear to be jumping on because of the f.get_best(...) not being the last line.是的@crunker99,你是对的,由于 f.get_best(...) 不是最后一行,笔记本似乎正在跳跃。
As such I set up an empty dataframe and captured the outputs as such.因此,我设置了一个空的 dataframe 并捕获了这样的输出。
df = pd.DataFrame({'Name': pd.Series([], dtype='str'),
'Output': pd.Series([], dtype='str')})
df.loc[n]=[col]+[f.get_best(method='sumsquare_error')]
Cheers!干杯! A bit silly on my side!
在我这边有点傻! haha
哈哈
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.