named_array
This is a python module that extends numpy array to be able to have column names to index with.
Installation
pip install named_array
Note that you need to have numpy installed already to use this module.
Usage
import numpy as np
from named_array import named_array
# the keyword arguments for named_array are exactly the same with numpy array,
# but with an extra keyword `colnames`, which is a list of the column names for each column
A = named_array([[1,2,3],[4,5,6]], colnames=['a', 'b', 'c'])
>>> A
named_array([[1, 2, 3],
[4, 5, 6]])
# you can index a column by name
>>> A['a']
named_array([1, 4])
# you can extract several columns as a new array
# by a tuple or a list of column names
>>> A['a', 'b']
array([[1, 2],
[4, 5]])
>>> A[['a', 'b']]
array([[1, 2],
[4, 5]])
# set the column names of the named_array
A.set_colnames(['a1', 'b1', 'c1'])
# you can also put a numpy array into the name_array constructor
# and turn it into a named_array
B = np.array([[1,2,3],[4,5,6]])
C = named_array(B, colnames=['a', 'b', 'c'])
# the column name could also be a tuple, where the first element is the column name,
# the second element is the number of columns the column name spans
A = named_array([[1,2,3],[4,5,6]], colnames=['a', ('b', 2)])
>>> A['b']
named_array([[2, 3],
[5, 6]])
Metadata
Release files for named-array 0.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| named_array-0.11.tar.gz | 11.9 kB | Without provenance | Details for named_array-0.11.tar.gz |
Release files / named_array-0.11.tar.gz
| Download URL | named_array-0.11.tar.gz |
|---|---|
| Size | 11.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
299a13cd84e7a47125d92890e567c8ac98ba32dde7996c4d50ce2d581bcb0f07
|
|
BLAKE2b-256 checksum How to use checksums |
1a675afb13674d6d5a2a7ed57d924cb470d7f191bb9787af9b0b43af6f7c588d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.5
|
Security for named-array 0.11
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.