요약
- 반복문의 진행상황을 확인
- 일반 반복문 및
apply()함수에서 활용 가능
1. 기본 활용법
from tqdm import tqdm
for i in tqdm(range(len(df))):
print(i)2. enumerate, zip, iterrows 활용
# 외부에서 감쌀 때 (total 옵션 사용)
for pair in tqdm(zip(list1, list2), total=len(list1)):
print(pair)
for idx, row in tqdm(df.iterrows(), total=len(df)):
print(idx, row)3. apply 함수에 적용
from tqdm import tqdm
tqdm.pandas()
df['col3'] = df.progress_apply(lambda x: x['col'] + x['col2'])
df['count'] = df['context'].progress_apply(lambda x: len(x.split()))참고사이트