#!/usr/bin/env python # coding: utf-8 # # Introduction # ipy_table is a supporting module for Jupyter Notebooks which makes it easy to create richly formatted data tables. # # The home page for ipy_table is at [epmoyer.github.com/ipy_table/](http://epmoyer.github.com/ipy_table/) # # ipy_table is maintained at [github.com/epmoyer/ipy_table](https://github.com/epmoyer/ipy_table) # In[1]: import add_parent_to_path # # Example # To create a table in interactive mode, import ipy_table and call ``make_table()`` on an array. # # Notes: # # * ipy_table can accept either a "native" array (a list of equal-length lists) or a ``numpy.ndarray``. # * Arrays passed to ipy_table typically contain integers, floats or strings, but in general they can contain other object types and ipy_table will render the result of calling ``str()`` on those objects. # In[2]: from ipy_table import * planets = [ ['Planet', 'Mass (kg)', 'Diameter (km)'], ['Mercury', 3.3022E23, 4879], ['Venus', 4.896E24, 12104], ['Earth', 5.972E24, 12735], ['Mars', 6.4191E23, 6772]]; make_table(planets) # The ``make_table()`` interface is interactive, so after calling ``make_table()`` we can call style formatting commands to modify the current table format. Here we'll apply the "basic" table theme. # # Note: Use "basic_left" for tables with row headers. Use "basic_both" for tables with row and coulmn headers. # In[3]: apply_theme('basic') # The Mass values are being fully expanded. By default ipy_table formats floating point numbers using the Python formatting string ``"%0.4f"``. We can override that by setting the ``float_format`` parameter. # # In[4]: set_global_style(float_format='%0.3E') # All cell formatting is dynamic. Custom formatting can be applied by calling ``set__style()``. # In[5]: set_row_style(3,color='yellow') # For documentation on all ipy_table commands, see the ipy_table reference notebook (ipy_table-Reference.ipynb) # In[ ]: