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 it in Jupyter Notebooks
In Jupyter Notebook it is 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(). But keep in mind that multidimensional arrays have nested tables.
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/settings 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
Release files for numpyprint 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| numpyprint-0.1.5.tar.gz | 2.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| numpyprint-0.1.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 5.0 kB
Release files / numpyprint-0.1.5.tar.gz
| Download URL | numpyprint-0.1.5.tar.gz |
|---|---|
| Size | 2.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a514c1754c4f67edcc0a7bc9d63bf868eed8908ee262adc963d0d9938e53d068
|
|
BLAKE2b-256 checksum How to use checksums |
14b1e27ec9ba818e30e1c7acd17a5a9de9bcb28852c8f07e0ba3d2fab80bb05c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / numpyprint-0.1.5-py3-none-any.whl
| Download URL | numpyprint-0.1.5-py3-none-any.whl |
|---|---|
| Size | 2.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4e8a73208c4cda4712bcd453b71ef15c15bf1a65fcbfc47c711a3a530e7042f1
|
|
BLAKE2b-256 checksum How to use checksums |
bb745aafaf17fd8a07824afddab7a41fc310f708f46e989ed4177ce820cce2e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|