Skip to content

Instantly share code, notes, and snippets.

@martjanz
Created August 13, 2019 15:43
Show Gist options
  • Save martjanz/52e62e69a1e1040e3cbffab3a107c21e to your computer and use it in GitHub Desktop.
Save martjanz/52e62e69a1e1040e3cbffab3a107c21e to your computer and use it in GitHub Desktop.
Python Notebook progress bar
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