简体   繁体   English

在下一个循环之前等待 Python 完成

[英]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.

相关问题 如何在 Python(和 Selenium)中的下一条语句之前等待 for 循环完成? - How to wait for the for loop to finish before next statement in Python (and Selenium)? Python:在继续循环之前等待进程完成? - Python: Wait for process to finish before proceeding in loop? Python子进程:在开始下一个命令之前等待命令完成? - Python subprocess: wait for command to finish before starting next one? 我不希望我的程序等待函数完成后再继续执行Python中的下一个任务 - I don't want my program to wait for a function to finish before moving on to the next task in Python Python 在 for 循环中的 os.system:如何在重新启动循环之前等待命令完成? - Python's os.system within a for loop: how to wait for a command to finish before re-starting the loop? 在继续Python之前,等待子进程.exe完成 - Wait for subprocess .exe to finish before proceeding in Python Scrapy:等待请求完成再执行下一个 - Scrapy: Wait for Request to finish before executing next one 让Python等待函数完成后再继续执行程序 - Have Python wait for a function to finish before proceeding with the program python urllib2-等待页面完成加载/重定向后才进行抓取? - python urllib2 - wait for page to finish loading/redirecting before scraping? 等待函数完成python - Wait for function to finish python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM