[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] getting an hline in a python generated table
From: |
John Kitchin |
Subject: |
Re: [O] getting an hline in a python generated table |
Date: |
Fri, 03 Apr 2015 16:18:10 -0400 |
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