Display multiple output tables in IPython notebook

2019-02-17 05:04发布

问题:

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

回答1:

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