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-0.2.1.tar.gz (9.7 kB view details)

Uploaded Source

File details

Details for the file unik-0.2.1.tar.gz.

File metadata

  • Download URL: unik-0.2.1.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for unik-0.2.1.tar.gz
Algorithm Hash digest
SHA256 d3cbb3d57ede8a02615aba31d6cb281e527586549bd4a66e0887945fa1aacd4f
MD5 686b454f559410a02f0ea945a4acee21
BLAKE2b-256 5e54cccc959597b627405b72c8298b6ac904f9de4a7cc1dec9fe5200647963f1

See more details on using hashes here.

Provenance

The following attestation bundles were made for unik-0.2.1.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