Skip to main content

Display numpy ndarrays in a pretty table in Jupyter notebooks

Project description

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.

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))
0123
00.06850.339930.199910.52213
10.142780.678340.321630.33468
20.630850.886660.808420.93526

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
01234
00.425920.842110.413960.747580.37527
10.81420.641740.742880.946110.28437
20.400140.61390.545940.2530.23285
30.0328320.707440.28510.771410.54845
40.737440.790150.850510.737910.49018
50.285150.319360.302160.190340.41642
60.28050.942050.152120.957430.5717
70.223450.716310.722490.665060.14654
80.237840.733450.357480.231250.7912
90.530080.858540.833610.866250.018584

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)

Project details


Download files

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

Source Distribution

ndpretty-0.0.3.tar.gz (5.4 kB view hashes)

Uploaded Source

Built Distribution

ndpretty-0.0.3-py3-none-any.whl (5.1 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