Title for table
Is there a way to gice a title to a table above the row header or under the table. It would be nice.
Is there a way to gice a title to a table above the row header or under the table. It would be nice.
I looked into the source code of table
and there is unfortunately no title or footer attribute, so you have to hack something yourself. I guess you are using the notebook, so you have to modify the html version of the table, with the following method : table ->html -> string -> add some title -> html back -> display
:
rows = [['a', 'b', 'c'], [100,2,3], [4,5,60]]
t = table(rows, header_row=True)
title = "My title"
footer = "My footer"
s = str(html(t))
new = '<h1>{}</h1> {}<h3>{}</h3>'.format(title,s,footer)
Now, you can see your hacked table with
html(new)
You can change the size of the title and footer my modifying the <h1>
and <h3>
tags.
Unfortunately here is the outcome in a notebook
'<h1>My title</h1> <div class="notruncate">\n<table class="table_form">\n<tbody>\n<tr>\n<th>a</th>\n<th>b</th>\n<th>c</th>\n</tr>\n<tr class ="row-a">\n<td><script type="math/tex">100</script></td>\n<td><script type="math/tex">2</script></td>\n<td><script type="math/tex">3</script></td>\n</tr>\n<tr class ="row-b">\n<td><script type="math/tex">4</script></td>\n<td><script type="math/tex">5</script></td>\n<td><script type="math/tex">60</script></td>\n</tr>\n</tbody>\n</table>\n</div><h3>My footer</h3>'
Please start posting anonymously - your entry will be published after you log in or create a new account.
Asked: 2021-01-06 12:10:25 +0100
Seen: 501 times
Last updated: Jan 06 '21