<div dir="ltr"><div><div><div>There's also a couple of tools to build tables, with unfortunately almost identical names:<br><br></div>- IPyTables (my code) - <a href="https://gist.github.com/takluyver/5098835">https://gist.github.com/takluyver/5098835</a> (I mean to rename this and make it a proper repo at some point)<br>

</div>- ipy_table -  <a href="https://github.com/epmoyer/ipy_table">https://github.com/epmoyer/ipy_table</a><br><br></div>Thomas<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 15 May 2014 18:11, Mark Voorhies <span dir="ltr"><<a href="mailto:mark.voorhies@ucsf.edu" target="_blank">mark.voorhies@ucsf.edu</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">On 05/14/2014 10:55 PM, Simon Cropper wrote:<br>
> Hi,<br>
><br>
> New to iPython and the standard set of tools bound to the server (e.g.<br>
> Pandas, etc).<br>
><br>
> What I was wondering is there a library, or a notebook showing the use<br>
> of the standard libraries bound to iPython, that allows tabular data to<br>
> be formatted.<br>
><br>
> Most examples I can find are essentially text dumps to the notebook. In<br>
> contrast, graphs and images have great formatting ability.<br>
><br>
> Why? I am looking at using iPython to data wrangle or munge large<br>
> biological datasets (plant names, biological and ecological attributes,<br>
> locational data). The notebook feature will allow others to visualize<br>
> and follow steps used to collate, convert, merge, summarize and analyze<br>
> this data.<br>
><br>
> Is this doable, or am I trying to use the notebook in the wrong way?<br>
><br>
> Any feedback would be appreciated.<br>
><br>
<br>
</div>I think Pandas is good at this, but I haven't played with it.<br>
<br>
A general strategy is to use HTML from IPython.core.display to render pretty HTML tables.<br>
<br>
Here's an example for tabular display of protein sequence alignments (with a horizontal<br>
scrollbar and green/red coloring of gaps/mutations):<br>
<br>
def tabformat(seqs, names = None):<br>
     """Return the given sequence alignment as a pretty HTML table.<br>
     seqs = list of strings with a common length (one letter amino-acid codes or "-" for gap)<br>
     names = sequence names as list of strings, same length as seqs<br>
     """<br>
     if(names is None):<br>
         names = [str(i) for i in xrange(len(seqs))]<br>
     retval = '<DIV style="font-family: monospace; font-size: small">\n'<br>
     retval += '<DIV><TABLE style="overflow: auto; position: relative; float: left; width: 8em">\n'<br>
     for n in names:<br>
         retval += "<TR><TD>%s</TD></TR>\n" % n<br>
     retval += "</TABLE></DIV>\n"<br>
     retval += '<DIV style="overflow: auto; width: 90em; position: relative; float: left"><TABLE>\n'<br>
     for i in seqs:<br>
         retval += "<TR>\n"<br>
         for (j,k) in zip(i,seqs[0]):<br>
             if(j != k):<br>
                 if(j == "-"):<br>
                     c = 'style="background-color: green"'<br>
                 else:<br>
                     c = 'style="background-color: red"'<br>
             else:<br>
                 c = ""<br>
             retval += '<TD %s>%s</TD>' % (c,j)<br>
         retval += "</TR>\n"<br>
     retval += "</TABLE></DIV>\n"<br>
     retval += "</DIV>\n"<br>
     return retval<br>
<br>
from IPython.core.display import HTML<br>
HTML(data = tabformat([i*100 for i in ("SPAM", "SPAM", "SCAM", "SPAM", "SPA-", "SPAM", "SPAN")]))<br>
<span class="HOEnZb"><font color="#888888"><br>
--Mark<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
_______________________________________________<br>
IPython-dev mailing list<br>
<a href="mailto:IPython-dev@scipy.org">IPython-dev@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/ipython-dev" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-dev</a><br>
</div></div></blockquote></div><br></div>