Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display multiple output tables in IPython notebook using Pandas

I now know that I can output multiple charts from IPython pandas by embedding them in one plot space which will appear in a single output cell in the notebook.

Can I do something similar with Pandas HTML Tables?

I am getting data from multiple tabs (about 15-20) on a spreadsheet and running them though a set of regressions and I'd like to display the results together, perhaps 2 up.. But since the function to display the table only displays one, the last one, not sure how to approach. Ideas?

I'd even be happy to display in successive output cells.. not real sure how to do that either But I guess I could do something really dirty calling each (spreadsheet) tab in a separate cell.. Ughh... FWIW I'm on IPython 2.0 dev and Pandas 13

like image 582
dartdog Avatar asked Jan 18 '14 18:01

dartdog


People also ask

How do I display multiple Dataframes in pandas?

How do I show two Dataframes in pandas? You can join pandas Dataframes in much the same way as you join tables in SQL. The concat() function can be used to concatenate two Dataframes by adding the rows of one to the other. concat() can also combine Dataframes by columns but the merge() function is the preferred way.

How do you display an entire output in Jupyter notebook?

To show the full data without any hiding, you can use pd. set_option('display.

What does %% do in Jupyter notebook?

Both ! and % allow you to run shell commands from a Jupyter notebook. % is provided by the IPython kernel and allows you to run "magic commands", many of which include well-known shell commands. ! , provided by Jupyter, allows shell commands to be run within cells.


1 Answers

This does it:

area-tabs=list(map(str, range(1, 28))) # for all 27 tabs
#area_tabs=['1','2'] # for specific tabs
for area_tabs in area_tabs:
    actdf,aname = get_data(area_tabs) #get_data gets the data and does a bunch or regression and table building
    aname,actdf,merged2,mergederrs,montdist,ols_test,mergedfcst=projections(actdf)
    IPython.display.display('Area: %s' % aname, mergederrs.tail(12))
    IPython.display.display('Area: %s' % aname, ols_test)
    IPython.display.display('Area: %s' % aname, merged2)

SO I can print all the results for each tab on the spreadsheet

like image 169
dartdog Avatar answered Sep 23 '22 15:09

dartdog