Use TQDM Progress Bar with Pandas Use TQDM Progress Bar with Pandas python python

Use TQDM Progress Bar with Pandas


Find length by getting shape

for index, row in tqdm(df.iterrows(), total=df.shape[0]):   print("index",index)   print("row",row)


with tqdm(total=Df.shape[0]) as pbar:        for index, row in Df.iterrows():        pbar.update(1)        ...


There is a workaround for tqdm > 4.24.As per https://github.com/tqdm/tqdm#pandas-integration:

from tqdm import tqdm        # Register `pandas.progress_apply` and `pandas.Series.map_apply` with `tqdm`# (can use `tqdm_gui`, `tqdm_notebook`, optional kwargs, etc.)tqdm.pandas(desc="my bar!")eurusd_ask['t_stamp'] = eurusd_ask['Gmt time'].progress_apply(lambda x: pd.Timestamp)eurusd_ask.set_index(['t_stamp'], inplace=True)