How can I print something in Python Pandas for some amount of time?
I would like to print a statement and I want the statement to disappear after n seconds? How do I do that in Python Pandas?
How can I print something in Python Pandas for some amount of time?
I would like to print a statement and I want the statement to disappear after n seconds? How do I do that in Python Pandas?
You can do this using os
module. You'll need to define your own print function using something like:
from os import system
import time
def temp_print(val: str):
print(val)
time.sleep(5)
system('cls')
Replace cls
command with clear
on Linux and MacOS.
EDIT: This works fine in console, but doesn't work in Jupyter notebooks. I'm not sure exactly how prints are handled there.
You can actually do this in Notebooks as well (ipython notebook clear cell output in code) so just modify the function like so:
import time
from IPython.display import clear_output
def temp_print(val: str):
print(val)
time.sleep(5)
clear_output()