Created
August 13, 2019 15:43
-
-
Save martjanz/52e62e69a1e1040e3cbffab3a107c21e to your computer and use it in GitHub Desktop.
Python Notebook progress bar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time, sys | |
from IPython.display import clear_output | |
def update_progress(progress): | |
bar_length = 50 | |
if isinstance(progress, int): | |
progress = float(progress) | |
if not isinstance(progress, float): | |
progress = 0 | |
if progress < 0: | |
progress = 0 | |
if progress >= 1: | |
progress = 1 | |
block = int(round(bar_length * progress)) | |
clear_output(wait = True) | |
text = "Progress: [{0}] {1:.1f}%".format( "#" * block + "-" * (bar_length - block), progress * 100) | |
print(text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment