Skip to content

deutschmn/ndpretty

Repository files navigation

ndpretty

Your little helper to display numpy ndarrays in a pretty table in Jupyter notebooks.

Jupyter notebooks are a great way to develop. ndpretty makes it even better for people who use numpy by providing nice formatting of ndarrays.

Open In Colab

Install

pip install ndpretty

How to use

import ndpretty
import numpy as np

Display an ndarray using ndarray_html():

ndpretty.ndarray_html(np.random.rand(3, 4))

If you want all np.ndarrays and torch.Tensors to be automatically formatted like this, load the default configuration:

ndpretty.default()

After this line has been exectued, all cell outputs that are np.ndarray or torch.Tensor are automatically formatted by ndpretty.

a = np.random.rand(10, 5)
a
10×5 float64 ndarray

It works with all numpy dtypes, multi-dimensional arrays and PyTorch tensors.

Find more usage examples here.

Why?

Look at the alternatives.

Author

Patrick Deutschmann (patrick@deutschmann.xyz)