How to use tqdm with map for Dataframes How to use tqdm with map for Dataframes pandas pandas

How to use tqdm with map for Dataframes


Due to the integration of tqdm with pandas you can use progress_map function instead of map function.

Note: for this to work you should add tqdm.pandas() line to your code.

So try this:

from tqdm import tqdmdef example(x):    x = x + 2    return xtqdm.pandas()  # <- added this lineif __name__ == '__main__':    dframe = pd.DataFrame([{'a':1, 'b': 1}, {'a':2, 'b': 2}, {'a':3, 'b': 3}])    dframe['b'] = dframe['b'].progress_map(example)  # <- progress_map here

Here is the documentation reference:

(after adding tqdm.pandas()) ... you can use progress_apply instead of apply and progress_map instead of map