Return Numpy and Pandas arrays as formatted LaTeX arrays.
Project description
The module array_to_latex converts a NumPy/SciPy array or Pandas Numerical DataFrame to a LaTeX array or table using Python 3.x style formatting of the result.
PLEASE PROVIDE BUG REPORTS! There are over 40,000 installs and no bug reports- but I’m finding them. I don’t have exhaustive tests, so I am missing things as I add features. Just let me know and I can quickly patch.
Play with it on mybinder.org!
Install using pip install --user array_to_latex from your command prompt, not the Python prompt.
Please read the help. It explains all options. To try it, see the online mybinder.org demo. It documents illustrates application to numerical Pandas DataFrames.
import numpy as np
import array_to_latex as a2l
A = np.array([[1.23456, 23.45678],[456.23, 8.239521]])
a2l.to_ltx(A, frmt = '{:6.2f}', arraytype = 'array')
will print the LaTeX code to your output.
import numpy as np
import array_to_latex as a2l
A = np.array([[1.23456, 23.45678],[456.23, 8.239521]])
latex_code = a2l.to_ltx(A, frmt = '{:6.2f}', arraytype = 'array')
will put the LaTeX code into variable latex_code.
import numpy as np
import array_to_latex as a2l
A = np.array([[1.23456, 23.45678],[456.23, 8.239521]])
a2l.to_clp(A, frmt = '{:6.2f}', arraytype = 'array')
will put the array onto your clipboard.
If you will be using the same conversion over and over, you can define your own by using a lambda function:
to_tex = lambda A : a2l.to_ltx(A, frmt = '{:6.2f}', arraytype = 'array', mathform=True)
to_tex(A)
so you can now use your function to_tex repeatedly with your specified settings. More detailed information on usage is in the help.
import array_to_latex as a2l
help(a2l.to_ltx)
An interesting alternative approach is np array to latex.
Like this module, buy me a coffee!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for array_to_latex-0.76-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 177acf07c4c8dae4efbc32b8f6e3dc60252f453db78ccdb24863322d05d2cbe5 |
|
MD5 | 5974f0e80547a8c77e7a7deb2f1347e8 |
|
BLAKE2b-256 | 6d5482f940cc331a74b76839df8faf67318d8f84a1664d35ab29cbdc557994a4 |