Skip to main content

prints numpy arrays nicely

Project description

NumpyPrint

Numpyprint uses the Package prettytable to print numpy arrays in a nice format. At the moment this works well until a 2D Dimension.

Installation

pip install numpyprint

or

python3 -m pip install numpyprint

What is it ?

NumpyPrint nicely prints an numpy array with the help of the package PrettyTable. It prints arrays of any dimension.

Example

import numpy as np
from numpyprint import np_print

numpy_array = np.random.rand(1,2,3)*100
np_print(numpy_array)

The output with the default settings looks like this:

+---+----------------------------+---------------------------+
| 0 | +---+--------------------+ | +---+-------------------+ |
|   | | 0 | 40.361415789985486 | | | 0 | 89.54304456427288 | |
|   | | 1 | 42.44964170184573  | | | 1 | 43.11298502039822 | |
|   | | 2 | 19.234562477482196 | | | 2 |  40.0682288789328 | |
|   | +---+--------------------+ | +---+-------------------+ |
+---+----------------------------+---------------------------+

It prints a nice table with frame boarders and row numbers.

How to use it

Print to Console

import numpy as np
import numpyprint as npp

array = np.random.rand(3, 2, 3)*100

npp.np_print(array)

# or with change of some settings

npp.np_print(array,precision= 2 ,row_numbers= True, column_numbers= True,odd_vertical= False,style='plain')

Use in Jupyter Notebook

In Jupyter Notebook is it possible to use HTML to format the output. The following command prints the numpy array in a nice table.

import numpy as np
import numpyprint as npp

array = np.random.rand(3, 2)

npp.np_display(array)

Get the PrettyTable Object

If you want the PrettyTable object you can use np_format()

import numpy as np
import numpyprint as npp

array = np.random.rand(3, 2)

table = npp.np_format(array)

Change the Default Settings

The defaults are:

defaults=dict({
    'row_numbers': True,
    'column_numbers': False,
    'precision': None, # None or int like 2
    'style': 'default', # 'default' or 'plain'
    'odd_vertical': True
})

It is possible to change it like:

import numpy as np
import numpyprint as npp

npp.defaults['precision'] = 2

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

numpyprint-0.1.4.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

numpyprint-0.1.4-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file numpyprint-0.1.4.tar.gz.

File metadata

  • Download URL: numpyprint-0.1.4.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.1

File hashes

Hashes for numpyprint-0.1.4.tar.gz
Algorithm Hash digest
SHA256 6fb1e0b2a5831c426f861b132243644d015bcd2003c82479da0b02fe6a27723d
MD5 0d084042b106b2b2980b840957771002
BLAKE2b-256 3b35541b7dc162b6f2c66281736273abe57a6bb1561cb3e49fb4ccf1c51440fc

See more details on using hashes here.

Provenance

File details

Details for the file numpyprint-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: numpyprint-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.1

File hashes

Hashes for numpyprint-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d55f2956a0cca4f0c6d43ca0000d28e23193339a3747bdca8e65830a8b95e07c
MD5 4a58932773523e68008c4f0d65a911b7
BLAKE2b-256 02558f46b52db239eac8d11822caa1344c456f32d8a2d908b8c5c43cd7b30abe

See more details on using hashes here.

Provenance

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