Provide functionality for working with selections of unique items in lists / arrays
Project description
unik
Provide functionality for working with selections of unique items in lists / arrays
Installation
You can install unik using pip:
pip install unik
Usage
>>> import numpy as np
>>> from unik import Unique
>>> items = [1, 2, 2, 2, 3, 1, 4, 3]
>>> un = Unique(items, verbose=True)
N value
==== ==========
2 1
3 2
2 3
1 4
>>> print(un.info(sort_counts=True))
N value
==== ==========
1 4
2 1
2 3
3 2
>>> items = np.array(['apples', 'apples', 'oranges', 'apples', 'grapes'])
>>> un = Unique(items, verbose=True)
N value
==== ==========
3 apples
1 grapes
1 oranges
>>> print(np.array(un.values)[un.counts > 1])
['apples']
>>> another_array = np.array(['tree', 'tree', 'tree', 'tree', 'vine'])
>>> for i in un.unique_index():
>>> print(f'{items[i]} grow on a {another_array[i]}')
apples grow on a tree
grapes grow on a vine
oranges grow on a tree
# __get__ builtin returns boolean array
>>> print(un['apples'])
[ True True False True False]
>>> print(items[~un['apples']])
['oranges' 'grapes']
>>> print(another_array[~un['apples']])
['tree' 'vine']
License
MIT License - see LICENSE file for details
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
unik-1.0.tar.gz
(9.6 kB
view details)
File details
Details for the file unik-1.0.tar.gz.
File metadata
- Download URL: unik-1.0.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9252393f820494a0fe1cfb2d3a37fa1b5bc47ff6b2f11e89fd9bc574b12f0520
|
|
| MD5 |
12345037df008f859e8300b3033e882d
|
|
| BLAKE2b-256 |
16392c7917060e5c426773975659fcc7cecea0f3e6b717e71e396e0bf5a699ec
|
Provenance
The following attestation bundles were made for unik-1.0.tar.gz:
Publisher:
publish-to-pypi.yml on gbrammer/unik
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
unik-1.0.tar.gz -
Subject digest:
9252393f820494a0fe1cfb2d3a37fa1b5bc47ff6b2f11e89fd9bc574b12f0520 - Sigstore transparency entry: 612174107
- Sigstore integration time:
-
Permalink:
gbrammer/unik@ce86500fb14969a917fef2bc3aee58295a6c6afe -
Branch / Tag:
refs/tags/1.0 - Owner: https://github.com/gbrammer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@ce86500fb14969a917fef2bc3aee58295a6c6afe -
Trigger Event:
release
-
Statement type: