Skip to main content

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


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)

Uploaded Source

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

Hashes for unik-1.0.tar.gz
Algorithm Hash digest
SHA256 9252393f820494a0fe1cfb2d3a37fa1b5bc47ff6b2f11e89fd9bc574b12f0520
MD5 12345037df008f859e8300b3033e882d
BLAKE2b-256 16392c7917060e5c426773975659fcc7cecea0f3e6b717e71e396e0bf5a699ec

See more details on using hashes here.

Provenance

The following attestation bundles were made for unik-1.0.tar.gz:

Publisher: publish-to-pypi.yml on gbrammer/unik

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page