tqdm 可以与绘图一起使用吗?
首次使用 tqdm 用户。进度条开始移动,但随后什么也不做。我也得到了一些有趣的图形输出
First-time tqdm user. The progress bar starts to move but then does nothing. I'm getting some interesting graph output as well ???? I guess it isn't meant to be used with plots? Am I supposed to pre-empt the plot output with another time method?
categ = data.iloc[:,categorical_indexes]
fig, axes = plt.subplots(6, 3, figsize = (20, 20))
for i, col in enumerate(tqdm_notebook(categ, desc = 'Progress()')):
column_values = data[col].value_counts()
labels = column_values.index
sizes = column_values.values
axes[i//3, i%3].pie(sizes, labels = labels, colors = sns.color_palette("YlOrBr"), autopct = '%1.0f%%', startangle = 90)
axes[i//3, i%3].axis('equal')
axes[i//3, i%3].set_title(col)
plt.show()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
categ
是一个长度为 103904 的 Iterable 吗?如果不是,这可能表明循环中的某些内容可能与您的预期不同。你是如何导入tqdm的?看到
tqdm_notebook
让我觉得您可能正在使用一种已弃用/维护得不好的方式来使用 tqdm 中的进度条。我通常在笔记本中使用 tqdm 的两种方式:
我之前在简单循环中使用 tqdm 来创建绘图,到目前为止还没有出现问题。如果您的问题仍然存在,请查看此 SO线程当程序中存在异步性或存在除系统控制台之外的文本输出连接时,解决 tqdm 潜在问题的解决方案。
Is
categ
an Iterable with a length of 103904? If not, this might be an indicator that something about the loop could be different from what you expect.How did you import tqdm? Seeing
tqdm_notebook
makes me think you might be using a deprecated/not that well maintained way of using the progress bar in tqdm.Two ways how I usually use tqdm in Notebooks:
I used tqdm in simple loops for creating plots before and did not have problems so far. If your problem persists check out this SO-thread for solutions to potential problems with tqdm when there is asynchronousity in your program or there are text output connections other than the system console.