This is probably a corner-case for most people, but it should be easy to check the environment and format the output depending on terminal/notebook. See
|
display(IPHTML(f"<table><tr><th>id</th><th>Year</th><th>Date</th><th>Time</th><th>Name</th><th>Notes</th></tr><tr>{table_code}</tr></table>")) |
for example.