Python library for extract property from data.
Project description
DataProperty
Summary
Python library for extract property from data.
Installation
pip install DataProperty
Usage
Extract property of data for each data from matrix
from dataproperty import PropertyExtractor, Typecode
data_matrix = [
[1, 1.1, "aaa", 1, 1],
[2, 2.2, "bbb", 2.2, 2.2],
[3, 3.3, "ccc", 3, "ccc"],
]
prop_matrix = PropertyExtractor.extract_data_property_matrix(data_matrix)
print "---------- typename ----------"
for prop_list in prop_matrix:
print [Typecode.get_typename(prop.typecode) for prop in prop_list]
print "---------- str_len ----------"
for prop_list in prop_matrix:
print [prop.str_len for prop in prop_list]
print "---------- integer_digits ----------"
for prop_list in prop_matrix:
print [prop.integer_digits for prop in prop_list]
print "---------- decimal_places ----------"
for prop_list in prop_matrix:
print [prop.decimal_places for prop in prop_list]
---------- typename ---------- ['INT', 'FLOAT', 'STRING', 'INT', 'INT'] ['INT', 'FLOAT', 'STRING', 'FLOAT', 'FLOAT'] ['INT', 'FLOAT', 'STRING', 'INT', 'STRING'] ---------- str_len ---------- [1, 3, 3, 1, 1] [1, 3, 3, 3, 3] [1, 3, 3, 1, 3] ---------- integer_digits ---------- [1, 1, nan, 1, 1] [1, 1, nan, 1, 1] [1, 1, nan, 1, nan] ---------- decimal_places ---------- [0, 1, nan, 0, 0] [0, 1, nan, 1, 1] [0, 1, nan, 0, nan]
Extract property of data for each column from matrix
from dataproperty import PropertyExtractor, Typecode
header_list = ["int", "float", "str", "num", "mix"]
data_matrix = [
[1, 1.1, "aaa", 1, 1],
[2, 2.2, "bbb", 2.2, 2.2],
[3, 3.3, "ccc", 3, "ccc"],
]
col_prop_list = PropertyExtractor.extract_column_property_list(header_list, data_matrix)
print "---------- typename ----------"
print [Typecode.get_typename(prop.typecode) for prop in col_prop_list]
print "---------- padding_len ----------"
print [prop.padding_len for prop in col_prop_list]
print "---------- decimal_places ----------"
print [prop.decimal_places for prop in col_prop_list]
---------- typename ---------- ['INT', 'FLOAT', 'STRING', 'FLOAT', 'STRING'] ---------- padding_len ---------- [3, 5, 3, 3, 3] ---------- decimal_places ---------- [nan, 1, nan, 1, 1]
Dependencies
Python 2.5+ or 3.3+
Test dependencies
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
DataProperty-0.2.1.tar.gz
(11.0 kB
view hashes)
Built Distribution
Close
Hashes for DataProperty-0.2.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9ce4539d0c7bb60166d06addf76478181d3a231fa259bc517ca3bb72dde21c1 |
|
MD5 | e76f059c1bb499c0af8b0276660e2481 |
|
BLAKE2b-256 | 320227f7a15d9ad9888f1cdf999a6231f5eb18e6fadea0c78fbddb23f82855eb |