Pandas printing in jupyter

boffi at questa.la.so boffi at questa.la.so
Sat Jan 13 16:57:35 EST 2018


Rustom Mody <rustompmody at gmail.com> writes:

> Specifically and for starters, I want a numpy array — lets say 2D to
> start with — to be displayed(displayable) as elegantly as sympy does
> to (its) matrices
########################################################################
import numpy as np
from IPython.display import Latex

def prmat(mat):
    return (r'\begin{bmatrix}' +
            r'\\'.join('&'.join('%f'%x for x in row) for row in mat) +
            r'\end{bmatrix}'

a = np.arange(12).reshape((3, 4))+1
display(Latex(prmat(a)))
########################################################################
you could add optional arguments to modify the type of brackets and the
formatting string



More information about the Python-list mailing list