Skip to main content

Python library for extract property from data.

Project description

DataProperty

https://img.shields.io/pypi/pyversions/DataProperty.svg https://travis-ci.org/thombashi/DataProperty.svg?branch=master https://coveralls.io/repos/github/thombashi/DataProperty/badge.svg?branch=master

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)

Uploaded Source

Built Distribution

DataProperty-0.2.1-py2.py3-none-any.whl (6.9 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page