How to fix tqdm progress_apply for pandas in Jupyter?

后端 未结 5 1953
别那么骄傲
别那么骄傲 2020-12-31 07:19

Don\'t really understand is it a mistake or just my local problem, still have some issues with using tqdm progress bars with progress_apply in Jupyter.

相关标签:
5条回答
  • 2020-12-31 07:34

    This is what I run in my jupyter notebooks, and then progress_apply works:

    from tqdm import tqdm, tqdm_notebook
    tqdm_notebook().pandas()
    

    I had been getting an error without the () after tqdm_notebook

    0 讨论(0)
  • 2020-12-31 07:36

    The following is working for me:

    from tqdm import tqdm
    tqdm.pandas()
    keywords_df['keyword'] = keywords_df['keywird'].progress_apply(lambda x: x.replace('*',''))
    
    0 讨论(0)
  • 2020-12-31 07:45

    Answer from tqdm developer:

    notebook support is still in a (late) beta stage. The API might change slightly when we release tqdm v5 but for now you probably need

    from tqdm._tqdm_notebook import tqdm_notebook
    
    tqdm_notebook.pandas(...
    
    0 讨论(0)
  • 2020-12-31 07:50

    Now you can just do:

    from tqdm.notebook import tqdm
    tqdm.pandas()
    
    df.progress_apply(...)
    

    My version of tqdm is 4.39.0

    0 讨论(0)
  • 2020-12-31 07:51

    Assuming your question is about how to use the status bar, vs the ascetics of the status bar on the Jupyter NoteBook then your code should be

    tqdm.pandas(desc="Example Desc")
    keywords_df['keyword'] = keywords_df['keywird'].progress_apply(lambda x: x.replace('*',''))
    
    0 讨论(0)
提交回复
热议问题