Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Python library for extract property from data.

Project Description
Home-page: https://github.com/thombashi/DataProperty
Author: Tsuyoshi Hombashi
Author-email: tsuyoshi.hombashi@gmail.com
License: MIT License
Description: **DataProperty**

.. image:: https://badge.fury.io/py/DataProperty.svg
:target: https://badge.fury.io/py/DataProperty

.. image:: https://img.shields.io/travis/thombashi/DataProperty/master.svg?label=Linux
:target: https://travis-ci.org/thombashi/DataProperty

.. image:: https://img.shields.io/appveyor/ci/thombashi/dataproperty/master.svg?label=Windows
:target: https://ci.appveyor.com/project/thombashi/dataproperty

.. image:: https://coveralls.io/repos/github/thombashi/DataProperty/badge.svg?branch=master
:target: https://coveralls.io/github/thombashi/DataProperty?branch=master


.. contents:: Table of contents
:backlinks: top
:local:


Summary
=======
A Python library for extract property from data.


Installation
============

::

pip install DataProperty


Usage
=====

Extract property of data
------------------------

e.g. Extract a ``float`` value property
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code:: python

>>> from dataproperty import DataProperty
>>> DataProperty(-1.1)
data=-1.1, typename=REAL_NUMBER, align=right, ascii_char_width=4, integer_digits=1, decimal_places=1, additional_format_len=1


e.g. Extract a ``int`` value property
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code:: python

>>> from dataproperty import DataProperty
>>> DataProperty(123456789)
data=123456789, typename=INTEGER, align=right, ascii_char_width=9, integer_digits=9, decimal_places=0, additional_format_len=0

e.g. Extract a ``str`` (ascii) value property
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code:: python

>>> from dataproperty import DataProperty
>>> DataProperty("sample string")
data=sample string, typename=STRING, align=left, length=13, ascii_char_width=13, additional_format_len=0

e.g. Extract a ``str`` (multi-byte) value property
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code:: python

>>> import six
>>> from dataproperty import DataProperty
>>> six.text_type(DataProperty("吾輩は猫である"))
data=吾輩は猫である, typename=STRING, align=left, length=7, ascii_char_width=14, additional_format_len=0

::

e.g. Extract a time (``datetime``) value property
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code:: python

>>> import datetime
>>> from dataproperty import DataProperty
>>> DataProperty(datetime.datetime(2017, 1, 1, 0, 0, 0))
data=2017-01-01 00:00:00, typename=DATETIME, align=left, ascii_char_width=19, additional_format_len=0

e.g. Extract a ``bool`` value property
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code:: python

>>> from dataproperty import DataProperty
>>> DataProperty(True)
data=True, typename=BOOL, align=left, ascii_char_width=4, additional_format_len=0


Extract data property for each element from a matrix
----------------------------------------------------
``DataPropertyExtractor.to_dataproperty_matrix`` method returns a matrix of ``DataProperty`` instances from a data matrix.
An example data set and the result are as follows:

.. code:: python

dt = datetime.datetime(2017, 1, 1, 0, 0, 0)
inf = float("inf")
nan = float("nan")

data_matrix = [
[1, 1.1, "aa", 1, 1, True, inf, nan, dt],
[2, 2.2, "bbb", 2.2, 2.2, False, "inf", "nan", dt],
[3, 3.33, "cccc", -3, "ccc", "true", inf, "NAN", "2017-01-01T01:23:45+0900"],
]

::

$ ./to_dataproperty_matrix.py
---------- typename ----------
['INTEGER', 'REAL_NUMBER', 'STRING', 'INTEGER', 'INTEGER', 'BOOL', 'INFINITY', 'NAN', 'DATETIME']
['INTEGER', 'REAL_NUMBER', 'STRING', 'REAL_NUMBER', 'REAL_NUMBER', 'BOOL', 'INFINITY', 'NAN', 'DATETIME']
['INTEGER', 'REAL_NUMBER', 'STRING', 'INTEGER', 'STRING', 'BOOL', 'INFINITY', 'NAN', 'STRING']

---------- data ----------
[1, Decimal('1.1'), 'aa', 1, 1, True, Decimal('Infinity'), Decimal('NaN'), datetime.datetime(2017, 1, 1, 0, 0)]
[2, Decimal('2.2'), 'bbb', Decimal('2.2'), Decimal('2.2'), False, Decimal('Infinity'), Decimal('NaN'), datetime.datetime(2017, 1, 1, 0, 0)]
[3, Decimal('3.33'), 'cccc', -3, 'ccc', True, Decimal('Infinity'), Decimal('NaN'), '2017-01-01T01:23:45+0900']

---------- align ----------
[right, right, left, right, right, left, left, left, left]
[right, right, left, right, right, left, left, left, left]
[right, right, left, right, left, left, left, left, left]

---------- length ----------
[1, 3, 2, 1, 1, 4, 8, 3, 19]
[1, 3, 3, 3, 3, 5, 8, 3, 19]
[1, 4, 4, 2, 3, 4, 8, 3, 24]

---------- integer_digits ----------
[1, 1, nan, 1, 1, nan, nan, nan, nan]
[1, 1, nan, 1, 1, nan, nan, nan, nan]
[1, 1, nan, 1, nan, nan, nan, nan, nan]

---------- decimal_places ----------
[0, 1, nan, 0, 0, nan, nan, nan, nan]
[0, 1, nan, 1, 1, nan, nan, nan, nan]
[0, 2, nan, 0, nan, nan, nan, nan, nan]

Full example source code can be found at *examples/py/to_dataproperty_matrix.py*


Extract property for each column from a matrix
------------------------------------------------------
``DataPropertyExtractor.to_col_dataproperty_list`` method returns a list of ``DataProperty`` instances from a data matrix. The list represents the properties for each column.
An example data set and the result are as follows:

Example data set and result are as follows:

.. code:: python

dt = datetime.datetime(2017, 1, 1, 0, 0, 0)
inf = float("inf")
nan = float("nan")

data_matrix = [
[1, 1.1, "aa", 1, 1, True, inf, nan, dt],
[2, 2.2, "bbb", 2.2, 2.2, False, "inf", "nan", dt],
[3, 3.33, "cccc", -3, "ccc", "true", inf, "NAN", "2017-01-01T01:23:45+0900"],
]

::

$ ./to_col_dataproperty_list.py
---------- typename ----------
['INTEGER', 'REAL_NUMBER', 'STRING', 'REAL_NUMBER', 'STRING', 'BOOL', 'INFINITY', 'NAN', 'STRING']

---------- align ----------
[right, right, left, right, left, left, left, left, left]

---------- ascii_char_width ----------
[3, 5, 4, 4, 3, 5, 8, 3, 24]

---------- decimal_places ----------
[0, 2, nan, 1, 1, nan, nan, nan, nan]


Full example source code can be found at *examples/py/to_col_dataproperty_list.py*


Dependencies
============
Python 2.7+ or 3.3+

- `typepy <https://github.com/thombashi/typepy>`__

Test dependencies
-----------------
- `pytest <https://pypi.python.org/pypi/pytest>`__
- `pytest-runner <https://pypi.python.org/pypi/pytest-runner>`__
- `tox <https://pypi.python.org/pypi/tox>`__

Keywords: data,property
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Release History

Release History

This version
History Node

0.25.6

History Node

0.25.5

History Node

0.25.4

History Node

0.25.3

History Node

0.25.2

History Node

0.25.1

History Node

0.25.0

History Node

0.24.4

History Node

0.24.3

History Node

0.24.2

History Node

0.24.1

History Node

0.24.0

History Node

0.23.0

History Node

0.22.0

History Node

0.21.1

History Node

0.21.0

History Node

0.20.4

History Node

0.20.3

History Node

0.20.2

History Node

0.20.1

History Node

0.20.0

History Node

0.19.0

History Node

0.18.1

History Node

0.18.0

History Node

0.17.0

History Node

0.16.2

History Node

0.16.1

History Node

0.16.0

History Node

0.15.2

History Node

0.15.1

History Node

0.15.0

History Node

0.14.0

History Node

0.13.9

History Node

0.13.8

History Node

0.13.7

History Node

0.13.6

History Node

0.13.5

History Node

0.13.3

History Node

0.13.2

History Node

0.13.1

History Node

0.13.0

History Node

0.12.0

History Node

0.11.2

History Node

0.11.1

History Node

0.11.0

History Node

0.10.1

History Node

0.10.0

History Node

0.9.0

History Node

0.8.1

History Node

0.8.0

History Node

0.7.2

History Node

0.7.1

History Node

0.7.0

History Node

0.6.0

History Node

0.5.4

History Node

0.5.3

History Node

0.5.2

History Node

0.5.1

History Node

0.5.0

History Node

0.4.1

History Node

0.4.0

History Node

0.3.1

History Node

0.3.0

History Node

0.2.9

History Node

0.2.8

History Node

0.2.7

History Node

0.2.6

History Node

0.2.5

History Node

0.2.4

History Node

0.2.3

History Node

0.2.2

History Node

0.2.1

History Node

0.2.0

History Node

0.1.0

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
DataProperty-0.25.6-py2.py3-none-any.whl (19.8 kB) Copy SHA256 Checksum SHA256 py2.py3 Wheel Aug 16, 2017
DataProperty-0.25.6.tar.gz (25.3 kB) Copy SHA256 Checksum SHA256 Source Aug 16, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting