tqdm 4.70.0 (also reproduces on master 96f2e60)
pandas 3.0.5
Python 3.11.14
darwin
DataFrame.progress_map uses the number of columns as the bar total, although pandas' DataFrame.map (the pandas>=2.1 replacement for applymap) calls the function once per element (df.size times).
import time
import pandas as pd
from tqdm import tqdm
tqdm.pandas()
df = pd.DataFrame({'a': range(100), 'b': range(100), 'c': range(100)})
df.progress_map(lambda x: time.sleep(0.001) or x)
Actual: 100%|##########| 3/3 [00:00<00:00, 29.85it/s] — the bar reaches 100% after 3 of 300 calls (1% of the work) and stays frozen there, because the update wrapper stops counting once t.n == t.total.
Expected: 100%|##########| 300/300, matching what progress_applymap shows for the identical elementwise operation (total = df.size).
Root cause: in tqdm.std.tqdm.pandas, the total precompute only special-cases df_function == 'applymap'; 'map' (registered for DataFrame since 4.66.2) falls through to the row/column-count branch. Note progress_map is now the only elementwise option on pandas>=3.0, which removed applymap.
Happy to submit a PR (one-line fix + test update).
read the known issues
environment, where applicable:
DataFrame.progress_mapuses the number of columns as the bar total, although pandas'DataFrame.map(the pandas>=2.1 replacement forapplymap) calls the function once per element (df.sizetimes).Actual:
100%|##########| 3/3 [00:00<00:00, 29.85it/s]— the bar reaches 100% after 3 of 300 calls (1% of the work) and stays frozen there, because the update wrapper stops counting oncet.n == t.total.Expected:
100%|##########| 300/300, matching whatprogress_applymapshows for the identical elementwise operation (total = df.size).Root cause: in
tqdm.std.tqdm.pandas, the total precompute only special-casesdf_function == 'applymap';'map'(registered forDataFramesince 4.66.2) falls through to the row/column-count branch. Noteprogress_mapis now the only elementwise option on pandas>=3.0, which removedapplymap.Happy to submit a PR (one-line fix + test update).