jkitchin / scimax

An emacs starterkit for scientists and engineers
Other
1.03k stars 121 forks source link

Question about tables #489

Closed Arjay-El closed 7 months ago

Arjay-El commented 9 months ago

Not an Issue: I have wrestled with all types of ways to get a nice table, simple but nice. with column headers and rows of data underneath using jupyter-python. Do you have a method you have used successfully to get a table in the .org file thats looks like the an ordinary table as described? When moving from python and ipython, I end up with a lot of error messages and googling. Perhaps a paper you wrote as an example org-code?

Thanks.

"How long does it take to learn Emacs?. I learn Emacs in one day...everyday."

jkitchin commented 9 months ago

Here are two ways you might get something you like:


#+BEGIN_SRC jupyter-python
import pandas as pd

pd.DataFrame([[1, 2],[3, 4]], columns=['x', 'y'])
#+END_SRC

#+RESULTS:
:RESULTS:
|   | x | y |
|---+---+---|
| 0 | 1 | 2 |
| 1 | 3 | 4 |
:END:

#+BEGIN_SRC jupyter-python
import tabulate

print(tabulate.tabulate([[1, 2],[3, 4]], headers=['x', 'y'], tablefmt='orgtbl'))
#+END_SRC

#+RESULTS:
:RESULTS:
| x | y |
|---+---|
| 1 | 2 |
| 3 | 4 |
:END: