GroupBy.progress_map always raises AttributeError: pandas has no GroupBy.map
- 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:
tqdm 4.69.0 (master 96f2e60), pandas 3.0.3, Python 3.13.13, win32
tqdm.pandas() registers progress_map on both groupby classes, but pandas has no map on either, so both raise as soon as they are called.
import pandas as pd
from tqdm import tqdm
tqdm.pandas()
df = pd.DataFrame({"g": [0, 0, 1], "v": [1, 2, 3]})
df.groupby("g").progress_map(lambda x: x) # AttributeError
df.groupby("g")["v"].progress_map(lambda x: x) # AttributeErrorAttributeError: 'DataFrameGroupBy' object has no attribute 'map'
AttributeError: 'SeriesGroupBy' object has no attribute 'map'hasattr is False for map on both objects here.
Cause: std.py:934 and std.py:940 register inner_generator('map') for SeriesGroupBy and DataFrameGroupBy. inner ends at std.py:923 with return getattr(df, df_function)(wrapper, **kwargs), and that attribute does not resolve on a groupby. A bar is created and closed first, so the failure surfaces after tqdm.pandas() has already rendered.
The two registrations arrived in a95cd88 ("pandas: add progress_map, fix tests", 2024-02-05). tests/tests_pandas.py exercises Series.progress_map (line 57) and DataFrame.progress_map (line 82), but neither groupby variant, which is why this stayed quiet.
Simplest fix looks like dropping both registrations, since an elementwise map over a groupby has no pandas counterpart to delegate to. I have only pandas 3.0.3 here, so I cannot say whether an older pandas exposed GroupBy.map.
Source: tqdm/tqdm