如何在Jupyter中为 pandas 修复tqdm progress_apply? [英] How to fix tqdm progress_apply for pandas in Jupyter?

查看:449
本文介绍了如何在Jupyter中为 pandas 修复tqdm progress_apply?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不是很了解这是一个错误还是我的本地问题,使用 tqdm进度栏仍然有一些问题和Jupyter中的 progress_apply .

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.

第一次尝试:

from tqdm import tqdm
tqdm_notebook.pandas(desc="Example Desc")
keywords_df['keyword'] = keywords_df['keywird'].progress_apply(lambda x: x.replace('*',''))

输出(无任何条形):

AttributeError: 'function' object has no attribute 'pandas'

第二次尝试:

from tqdm import tqdm
tqdm_notebook().pandas(desc="Example Desc")
keywords_df['keyword'] = keywords_df['keywird'].progress_apply(lambda x: x.replace('*',''))

输出: 两根酒吧(需要一个).第一个栏为空(0it [00:00,?it/s]),第二个栏为OK.

Output: Two bars (need one). First bar is empty (0it [00:00, ?it/s]), second is OK.

有什么想法如何更改 progress_apply 描述和显示栏,而没有空白的初始化栏? :)

Any ideas how to change progress_apply description and display bar without empty initialization bar? :)

PS 文档( https://github.com/tqdm/tqdm )说我可以只使用 tqdm_notebook ,但这对我不起作用:)

P.S. Documentation (https://github.com/tqdm/tqdm) says I can just use tqdm_notebook, but it's not working for me :)

# Register `pandas.progress_apply` and `pandas.Series.map_apply` with `tqdm`
# (can use `tqdm_gui`, `tqdm_notebook`, optional kwargs, etc.)
tqdm.pandas(desc="my bar!")

推荐答案

答案来自tqdm开发人员:

Answer from tqdm developer:

笔记本电脑的支持仍处于(后期)测试阶段. API可能会更改 在我们发布tqdm v5时稍有不同,但目前您可能需要

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(...

这篇关于如何在Jupyter中为 pandas 修复tqdm progress_apply?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆