Skip to main content

zipdist

Keeping NumPy and Pandas attributes of python classes nice and tidy

Build Status Coverage Status PyPI version

The Zipdist2 class provides methods for saving and reloading NumPy arrays and Pandas DataFrame object attributes.

Complex attributes are saved to a single .tar.gz file.

The contents of the .tar.gz provides a tidy human-readable record of Pandas and Numpy Python class attributes as .csv and binary files.

Install

pip install zipdist==0.1.3

Basic Example

from zipdist.zip2 import Zipdist2
import pandas as pd
import numpy as np
import os

class X():
	def __init__(self, name):
		self.name = name

x = X(name = 'example_target_object')
x.example_simple_attr = [1989, 2020]
x.example_np_attr = np.array([[0, 1, 2, 3], [4, 5, 6, 7]])
x.example_pd_attr  = pd.DataFrame({"A":[1,2,3], "B":[2,4,6]})

z = Zipdist2(name = "zipper", target = x)
z._save(dest = "archive", dest_tar = "archive.tar.gz")
assert os.path.isfile("archive.tar.gz")
Saving example_np_attr to .csv : archive/example_np_attr.csv
Saving example_np_attr to .npy : archive/example_np_attr.npy
Saving example_pd_attr to .csv : archive/example_pd_attr.csv
Saving example_pd_attr to .feather : archive/example_pd_attr.feather
Saving JSON with complex attribute definitions : archive/complex_attributes.json
Saving JSON with simple attribute definitions : archive/simple_attributes.json
Combining saved files in : [archive.tar.gz].

Contents of archive.tar.gz

archive
├── complex_attributes.json
├── example_np_attr.csv
├── example_np_attr.npy
├── example_pd_attr.csv
├── example_pd_attr.feather
└── simple_attributes.json

Reload All Attributes of a Target Object with ._build()

x_new = X(name = 'example_target_object')
z = Zipdist2(name = "zipper", target = x_new)
# You can use the z._build() and reload all object attributes
z._build(target = x_new, dest = "archive", dest_tar = "archive.tar.gz")
Setting simple attribute name to example_target_object
Setting simple attribute example_simple_attr to [1989, 2020]
Setting [npy] to [np.ndarray] for attribute example_np_attr from: example_np_attr.npy
Setting [feather] to [pd.DataFrame] for attribute example_pd_attr from: example_pd_attr.feather

For instance:

>>>	x_new.example_simple_attr:
[1989, 2020]
>>>	x_new.example_np_attr:
[[0 1 2 3]
 [4 5 6 7]]
>>>	x_new.example_pd_attr:
   A  B
0  1  2
1  2  4
2  3  6

Reload Simple and Complex Object Attributes One by One with ._ready(), _reload_simple(), and _reload_complex().

# You can alternatively use the z._ready() and reload object attributes one by one
x_new = X(name = 'example_target_object')
z = Zipdist2(name = "zipper", target = x_new)
z._ready(target = x_new, dest = "archive", dest_tar = "archive.tar.gz")
z._reload_complex(k='example_np_attr')
z._reload_simple(k='example_simple_attr')

Metadata

Release files for zipdist 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zipdist 0.1.5
File Size Uploaded
zipdist-0.1.5.tar.gz 12.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for zipdist 0.1.5
File Interpreter ABI Platform
zipdist-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 30.6 kB

Release files / zipdist-0.1.5.tar.gz

Download URL zipdist-0.1.5.tar.gz
Size 12.5 kB
Tags Source
SHA-256 checksum
How to use checksums
78185d2c01253f8c911a0f6d6a924a8622b0a0d3db351e04c093c956e823f262
BLAKE2b-256 checksum
How to use checksums
ddab8e3789d6780e54e3af9568d76430c5a7934cd51e11c247fea98b65ebba36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.8.3

Release files / zipdist-0.1.5-py3-none-any.whl

Download URL zipdist-0.1.5-py3-none-any.whl
Size 18.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cb65d12c6ca504596bbd803397bc262958c00506a81d9874735231f1f2133285
BLAKE2b-256 checksum
How to use checksums
caa72c4907e3f5389664c67e533286c77c69a1b005bd112dee5488f7bfb8ee66
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.8.3

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page