From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: getting an hline in a python generated table Date: Fri, 03 Apr 2015 16:18:10 -0400 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:42672) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ye82i-0001CF-HH for emacs-orgmode@gnu.org; Fri, 03 Apr 2015 16:18:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ye82e-0003Yh-TU for emacs-orgmode@gnu.org; Fri, 03 Apr 2015 16:18:16 -0400 Received: from smtp.andrew.cmu.edu ([128.2.105.204]:58559) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ye82e-0003Yd-Oh for emacs-orgmode@gnu.org; Fri, 03 Apr 2015 16:18:12 -0400 In-reply-to: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Ken Mankoff Cc: Orgmode Mailing List cool, thanks for the tip. I was not awware of that library. Ken Mankoff writes: > Sorry about that. I switched out of Org mode in my email client so C-c C-c sent the email instead of executing the code block. I was mid-sentence... > > #+BEGIN_SRC python :results table :exports results :session > from tabulate import tabulate > import pandas as pd > df = pd.DataFrame(np.random.rand(2,2), index=['foo','bar']) > tab = tabulate(df, ['col1','col2'], tablefmt='orgtbl') > tab[1:-1] > #+END_SRC > #+RESULTS: > | | col1 | col2 | > |-----+----------+----------| > | foo | 0.223272 | 0.433449 | > | bar | 0.855854 | 0.13685 | > > I'm compensating for some bugs here. The tab[1:-1] is from, I think, tabulate, or perhaps IPython. I don't get results without this being a :session. If you don't use IPython/elpy in Org, then your final statement may need to be different (add a 'return'?) to get this to work. > > Hope this helps with w/ tables + headers, > > -k. -- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu