Skip to main content

Return Numpy and Pandas arrays as formatted LaTeX arrays.

Project description

https://badge.fury.io/py/array-to-latex.png/ https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg PyPi Download stats https://mybinder.org/badge_logo.svg

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!

0.70: Added mathform. When set to True (default), returns \(\times 10^n\) form. 0.71: Line breaks broke readme.rst on pypi. No code change. 0.72: Line breaks broke readme.rst on pypi. No code change.

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]])
a2l.to_clp(A, frmt = '{:6.2f}', arraytype = 'array')

will put the array onto your clipboard.

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!

New in 0.37: Now handles complex arrays.
New in 0.38: Aligns columns neatly.
0.40: Critical upgrade- 0.37-0.38 formatted incorrectly.
0.41: Critical upgrade- 0.37-0.40 formatted incorrectly.
New in 0.43: Now handles 1-D Arrays. See new option row
New in 0.50: Now works with Pandas DataFrames
0.51: Bug fix- remove extra blank lines in DataFrame tabular output
0.52: A few documentation typos fixed. No code changed.
0.60: Now handles strings in Pandas Dataframes. Fixes bug in exponentials and handling of exponentials. Please report errors!
0.61: Minor documentation improvements. No code changed.
0.70: Added mathform. When set to True (default), returns \(\times 10^n\) form.
0.71: Line breaks broke readme.rst on pypi. No code change.
0.72: Line breaks broke readme.rst on pypi. No code change.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

array_to_latex-0.72-py3-none-any.whl (5.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page