Skip to main content

An easy way to index lists in python

Project description

quickindex

A simple way to re-index json data in python

Example Usage

Input

from quickindex import TreeIndex
data_list = [
    {
        "first_name": "Davina",
        "last_name": "Emmy",
        "age": 25
    },
    {
        "first_name": "Kondwani",
        "last_name": "Busch",
        "age": 25
    },
    {
        "first_name": "Betty",
        "last_name": "Shannon",
        "age": 32
    },
    {
        "first_name": "Claude",
        "last_name": "Shannon",
        "age": 38
    }
]
age_index = TreeIndex(lambda x: (x["age"], x["last_name"]), lambda x: x["first_name"])
age_index.add_list(data_list)
print(age_index.as_dict())

Output

{
    25: {
        'Emmy': ['Davina'], 
        'Busch': ['Kondwani']
    }, 
    32: {
        'Shannon': ['Betty']
    }, 
    38: {
        'Shannon': ['Claude']
    }
}

Input

from quickindex import FlatIndex
data_list = [
    {
        "first_name": "Davina",
        "last_name": "Emmy",
        "age": 25
    },
    {
        "first_name": "Kondwani",
        "last_name": "Busch",
        "age": 25
    },
    {
        "first_name": "Betty",
        "last_name": "Shannon",
        "age": 32
    },
    {
        "first_name": "Claude",
        "last_name": "Shannon",
        "age": 38
    }
]
age_index = FlatIndex(lambda x: (x["age"], x["last_name"]), lambda x: x["first_name"])
age_index.add_list(data_list)
print(age_index.as_dict())

Output

{
    (25, 'Emmy'): ['Davina'], 
    (25, 'Busch'): ['Kondwani'], 
    (32, 'Shannon'): ['Betty'], 
    (38, 'Shannon'): ['Claude']
}

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

quickindex-1.1.0.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

quickindex-1.1.0-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file quickindex-1.1.0.tar.gz.

File metadata

  • Download URL: quickindex-1.1.0.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.6

File hashes

Hashes for quickindex-1.1.0.tar.gz
Algorithm Hash digest
SHA256 48e14e6cef21aaa3d12636f3f761355b197e4ab118d4e85b36bd61f355356d71
MD5 e5c7f50ba6ede001a316d55596f050c8
BLAKE2b-256 e87512460a2576bcbc721aa4cc7394009909f5ca44d5ad81902423267c0bd98c

See more details on using hashes here.

File details

Details for the file quickindex-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: quickindex-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.6

File hashes

Hashes for quickindex-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 30ea26eee224b49b3634b9db1e6a0871b7f6512cd732a62b1fb02fdaa73cc639
MD5 26187ddb8a0d71cdfde2c89212de6b43
BLAKE2b-256 291ee87a55ee10f86f9ab7a70d19183bd2fc043497066f1254861ab4c90607b2

See more details on using hashes here.

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