Skip to main content

Read, write, and query sparse tables

Project description

TestStatus PyPiStatus BlackStyle BlackPackStyle MITLicenseBadge

Query, write, read, and dynamically grow a sparse numeric table. I do love pandas.DataFrame and I do love numpy.recarray. But when the table is sparse and still won’t fit into your memory one needs to combine the best of pandas, numpy and zipfile to get the job done. This is the Sparse Numeric Table.

Install

pip install sparse-numeric-table-sebastian-achim-mueller

Test

pytest .

Fileformat

Efficient write and read using binary blocks (numpy dumps) in a zip file. On read, you only need to read the columns and indices you need. No need to read the entire file. Files can be explored with any zip file reader.

Usage

See ./sparse_numeric_table/tests for examples.

1st) You create a dict representing the dtypes of your table. Columns which only appear together are bundeled into a level . Each level has an index to merge and join with other levels.

my_table_dtypes = {
    "A": [
        ("a", "<u8"),
        ("b", "<f8"),
        ("c", "<f4"),
    ],
    "B": [
        ("g", "<i8"),
    ],
    "C": [
        ("m", "<i2"),
        ("n", "<u8"),
    ],
}

Here A , B , and C are the level keys. a, ... , n are the column keys.

2nd) You create/read/write the table.

 A             B         C

 idx a b c     idx g     idx m n
 ___ _ _ _     ___ _
|_0_|_|_|_|   |_0_|_|
|_1_|_|_|_|
|_2_|_|_|_|    ___ _
|_3_|_|_|_|   |_3_|_|
|_4_|_|_|_|   |_4_|_|    ___ _ _
|_5_|_|_|_|   |_5_|_|   |_5_|_|_|
|_6_|_|_|_|
|_7_|_|_|_|
|_8_|_|_|_|    ___ _
|_9_|_|_|_|   |_9_|_|
|10_|_|_|_|   |10_|_|
|11_|_|_|_|    ___ _     ___ _ _
|12_|_|_|_|   |12_|_|   |12_|_|_|
|13_|_|_|_|    ___ _
|14_|_|_|_|   |14_|_|

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

Built Distribution

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

File details

Details for the file sparse_numeric_table_sebastian_achim_mueller-1.0.6.tar.gz.

File metadata

File hashes

Hashes for sparse_numeric_table_sebastian_achim_mueller-1.0.6.tar.gz
Algorithm Hash digest
SHA256 14c37d05f0bddc91877f3bc8f41d7336fefad13e1a01a1f3e1c046804fab80dd
MD5 80949134cad3c9644007a46c261ba7c5
BLAKE2b-256 b377a6a03f7b596d6c3c41312006a0e78eec7fcc69bf6b663c85e5b2efee4a76

See more details on using hashes here.

File details

Details for the file sparse_numeric_table_sebastian_achim_mueller-1.0.6-py3-none-any.whl.

File metadata

File hashes

Hashes for sparse_numeric_table_sebastian_achim_mueller-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 388c73c64a2bfd06f9bdfdcfbef67ff19e784b5e1d89f623af98d75bf9c4a8c6
MD5 cf46d20f1af61caf1927859fdf1867bb
BLAKE2b-256 df7503dc53c0a9ae060b18ade7b158a5f5328d323b558acebd2356ab97c65f59

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