def getTEvents(gRaw, h):
    tEvents, sPos, sNeg = [], 0, 0
    diff = np.log(gRaw).diff().dropna()
    for i in tqdm(diff.index[1:]):
            pos, neg = float(sPos+diff.loc[i]), float(sNeg+diff.loc[i])
        except Exception as e:
            print (e)
            print (sPos+diff.loc[i], type(sPos+diff.loc[i]))
            print(sNeg+diff.loc[i], type(sNeg+diff.loc[i]))
        sPos, sNeg=max(0., pos), min(0., neg)
        if sNeg<-h:
        elif sPos>h:
    return pd.DatetimeIndex(tEvents)       

getTEvents(df0['Close'], 10000) #

Name Error: tdqm not defined

I don't understand what tdqm is either and where the cusum is done.


1 Answer 1


tqdm is a simple package for progress bars in Python. I am not familiar with the code you have copy pasted but most likely you haven't installed tqdm on your machine. You can find more documentation here (a quick google search would have revealed this as well). To fix your issue, you can run pip install tqdm in cmd and then import the package in your Python script via from tqdm import tqdm.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.