tqdm makes it easy to display a progress bar to check the progress of time-consuming processes such as for statements.
$ pip install tqdm
To use it, just enclose the iterable object in tqdm.
tqdm_test.py
from tqdm import tqdm
df = pd.read_csv("data.csv", encoding="UTF-8")
#Consider a scene where pandas data is processed for statement
#To use tqdm, just enclose it in tqdm
for row, item in tqdm(df.iterrows()):
print(item)
Until now, I have only used the above method. However, for some reason, the upper limit of the progress bar became "?", So I found out how to set the maximum number manually, so I will write it as a memorandum for myself.
tqdm_test.py
from tqdm import tqdm
df = pd.read_csv("data.csv", encoding="UTF-8")
#How to manually update the progress bar at the end of the for statement by enclosing it in the with statement
#total=Set the upper limit with. This time, I chose the number of df. The increase is.pbar.Specify with update.
with tqdm(total=len(df)) as pbar:
for row, item in tqdm(dataframe.iterrows()):
print(item)
pbar.update(1)
With from tqdm.notebook
, it became an easy-to-read progress bar.
tqdm_test.py
from tqdm.notebook import tqdm