Skip to content

DataFrame.progress_map shows wrong total (number of columns) and freezes at 100% #1798

Description

@2sumtech
  • I have marked all applicable categories:
    • exception-raising bug
    • visual output bug
  • I have visited the source website, and in particular
    read the known issues
  • I have searched through the issue tracker for duplicates
  • I have mentioned version numbers, operating system and
    environment, where applicable:
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).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions