1

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

enter image description here

Edison
  • 11,881
  • 5
  • 42
  • 50

1 Answers1

0

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:

from tqdm.notebook import tqdm

# as progress bar where you manually update
pbar = tqdm(desc="x", total=10)  # total is optional
for i in range(10):
    pbar.update(1)
    continue
pbar.close()
# alternative: 'with tqdm(desc="x", total=10) as pbar:' + skip the 'pbar.close()'

# wrapped around the iterable
for i in tqdm(range(10), desc="y"):
    continue

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.

ewz93
  • 2,444
  • 1
  • 4
  • 12