---
title: "DataProperty | pypx"
description: "Python library for extract property from data."
canonical_url: "https://pypx.app/packages/DataProperty"
meta:
  "og:description": "Python library for extract property from data."
  "og:image": "https://pypx.app/_og/d/h_630%2Cc_PackageCard%2Cname_DataProperty%2Cversion_1.1.1%2Csummary_Python%2Blibrary%2Bfor%2Bextract%2Bproperty%2Bfrom%2Bdata.%2Clicense_MIT%2BLicense%2Cp_Ii9wYWNrYWdlcy9EYXRhUHJvcGVydHki%2Cs_NjweOQ4NqX8qCue1.png"
  "og:image:height": "630"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "DataProperty 1.1.1"
  "twitter:image": "https://pypx.app/_og/d/h_630%2Cc_PackageCard%2Cname_DataProperty%2Cversion_1.1.1%2Csummary_Python%2Blibrary%2Bfor%2Bextract%2Bproperty%2Bfrom%2Bdata.%2Clicense_MIT%2BLicense%2Cp_Ii9wYWNrYWdlcy9EYXRhUHJvcGVydHki%2Cs_NjweOQ4NqX8qCue1.png"
---

> Index of every page on this site: [llms.txt](https://pypx.app/llms.txt)

# **DataProperty**

v1.1.1

Python library for extract property from data.

27 KB Python 3.9+ py3-none-anyMIT License2 deps

[**Diff **](https://pypx.app/packages/DataProperty/diff)

`$ uv add DataProperty`

# Summary

A Python library for extract property from data.

![PyPI package version](https://badge.fury.io/py/DataProperty.svg) ![conda-forge package version](https://anaconda.org/conda-forge/DataProperty/badges/version.svg) ![Supported Python versions](https://img.shields.io/pypi/pyversions/DataProperty.svg) ![Supported Python implementations](https://img.shields.io/pypi/implementation/DataProperty.svg) ![CI status of Linux/macOS/Windows](https://github.com/thombashi/DataProperty/actions/workflows/ci.yml/badge.svg) ![Test coverage](https://coveralls.io/repos/github/thombashi/DataProperty/badge.svg?branch=master) ![CodeQL](https://github.com/thombashi/DataProperty/actions/workflows/github-code-scanning/codeql/badge.svg)

# Installation

## Installation: pip

```
pip install DataProperty
```

## Installation: conda

```
conda install -c conda-forge dataproperty
```

## Installation: apt

```
sudo add-apt-repository ppa:thombashi/ppa
sudo apt update
sudo apt install python3-dataproperty
```

# Usage

## Extract property of data

### e.g. Extract a float value property

```python
>>> from dataproperty import DataProperty
>>> DataProperty(-1.1)
data=-1.1, type=REAL_NUMBER, align=right, ascii_width=4, int_digits=1, decimal_places=1, extra_len=1
```

### e.g. Extract a int value property

```python
>>> from dataproperty import DataProperty
>>> DataProperty(123456789)
data=123456789, type=INTEGER, align=right, ascii_width=9, int_digits=9, decimal_places=0, extra_len=0
```

### e.g. Extract a str (ascii) value property

```python
>>> from dataproperty import DataProperty
>>> DataProperty("sample string")
data=sample string, type=STRING, align=left, length=13, ascii_width=13, extra_len=0
```

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

```python
>>> from dataproperty import DataProperty
>>> str(DataProperty("吾輩は猫である"))
data=吾輩は猫である, type=STRING, align=left, length=7, ascii_width=14, extra_len=0
```

### e.g. Extract a time (datetime) value property

```python
>>> import datetime
>>> from dataproperty import DataProperty
>>> DataProperty(datetime.datetime(2017, 1, 1, 0, 0, 0))
data=2017-01-01 00:00:00, type=DATETIME, align=left, ascii_width=19, extra_len=0
```

### e.g. Extract a bool value property

```python
>>> from dataproperty import DataProperty
>>> DataProperty(True)
data=True, type=BOOL, align=left, ascii_width=4, extra_len=0
```

## Extract data property for each element from a matrix

DataPropertyExtractor.to\_dp\_matrix method returns a matrix of DataProperty instances from a data matrix. An example data set and the result are as follows:

:Sample Code:

```python
import datetime
from dataproperty import DataPropertyExtractor

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

dp_matrix = dp_extractor.to_dp_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"],
])

for row, dp_list in enumerate(dp_matrix):
    for col, dp in enumerate(dp_list):
        print("row={:d}, col={:d}, {}".format(row, col, str(dp)))
```

:Output: ::

row=0, col=0, data=1, type=INTEGER, align=right, ascii\_width=1, int\_digits=1, decimal\_places=0, extra\_len=0 row=0, col=1, data=1.1, type=REAL\_NUMBER, align=right, ascii\_width=3, int\_digits=1, decimal\_places=1, extra\_len=0 row=0, col=2, data=aa, type=STRING, align=left, ascii\_width=2, length=2, extra\_len=0 row=0, col=3, data=1, type=INTEGER, align=right, ascii\_width=1, int\_digits=1, decimal\_places=0, extra\_len=0 row=0, col=4, data=1, type=INTEGER, align=right, ascii\_width=1, int\_digits=1, decimal\_places=0, extra\_len=0 row=0, col=5, data=True, type=BOOL, align=left, ascii\_width=4, extra\_len=0 row=0, col=6, data=Infinity, type=INFINITY, align=left, ascii\_width=8, extra\_len=0 row=0, col=7, data=NaN, type=NAN, align=left, ascii\_width=3, extra\_len=0 row=0, col=8, data=2017-01-01 00:00:00, type=DATETIME, align=left, ascii\_width=19, extra\_len=0 row=1, col=0, data=2, type=INTEGER, align=right, ascii\_width=1, int\_digits=1, decimal\_places=0, extra\_len=0 row=1, col=1, data=2.2, type=REAL\_NUMBER, align=right, ascii\_width=3, int\_digits=1, decimal\_places=1, extra\_len=0 row=1, col=2, data=bbb, type=STRING, align=left, ascii\_width=3, length=3, extra\_len=0 row=1, col=3, data=2.2, type=REAL\_NUMBER, align=right, ascii\_width=3, int\_digits=1, decimal\_places=1, extra\_len=0 row=1, col=4, data=2.2, type=REAL\_NUMBER, align=right, ascii\_width=3, int\_digits=1, decimal\_places=1, extra\_len=0 row=1, col=5, data=False, type=BOOL, align=left, ascii\_width=5, extra\_len=0 row=1, col=6, data=Infinity, type=INFINITY, align=left, ascii\_width=8, extra\_len=0 row=1, col=7, data=NaN, type=NAN, align=left, ascii\_width=3, extra\_len=0 row=1, col=8, data=2017-01-01 00:00:00, type=DATETIME, align=left, ascii\_width=19, extra\_len=0 row=2, col=0, data=3, type=INTEGER, align=right, ascii\_width=1, int\_digits=1, decimal\_places=0, extra\_len=0 row=2, col=1, data=3.33, type=REAL\_NUMBER, align=right, ascii\_width=4, int\_digits=1, decimal\_places=2, extra\_len=0 row=2, col=2, data=cccc, type=STRING, align=left, ascii\_width=4, length=4, extra\_len=0 row=2, col=3, data=-3, type=INTEGER, align=right, ascii\_width=2, int\_digits=1, decimal\_places=0, extra\_len=1 row=2, col=4, data=ccc, type=STRING, align=left, ascii\_width=3, length=3, extra\_len=0 row=2, col=5, data=True, type=BOOL, align=left, ascii\_width=4, extra\_len=0 row=2, col=6, data=Infinity, type=INFINITY, align=left, ascii\_width=8, extra\_len=0 row=2, col=7, data=NaN, type=NAN, align=left, ascii\_width=3, extra\_len=0 row=2, col=8, data=2017-01-01T01:23:45+0900, type=STRING, align=left, ascii\_width=24, length=24, extra\_len=0

Full example source code can be found at *examples/py/to\_dp\_matrix.py*

## Extract properties for each column from a matrix

DataPropertyExtractor.to\_column\_dp\_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:

:Sample Code:

```python
import datetime
from dataproperty import DataPropertyExtractor

dp_extractor = DataPropertyExtractor()
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"],
]

dp_extractor.headers = ["int", "float", "str", "num", "mix", "bool", "inf", "nan", "time"]
col_dp_list = dp_extractor.to_column_dp_list(dp_extractor.to_dp_matrix(dp_matrix))

for col_idx, col_dp in enumerate(col_dp_list):
    print(str(col_dp))
```

:Output: ::

column=0, type=INTEGER, align=right, ascii\_width=3, bit\_len=2, int\_digits=1, decimal\_places=0 column=1, type=REAL\_NUMBER, align=right, ascii\_width=5, int\_digits=1, decimal\_places=(min=1, max=2) column=2, type=STRING, align=left, ascii\_width=4 column=3, type=REAL\_NUMBER, align=right, ascii\_width=4, int\_digits=1, decimal\_places=(min=0, max=1), extra\_len=(min=0, max=1) column=4, type=STRING, align=left, ascii\_width=3, int\_digits=1, decimal\_places=(min=0, max=1) column=5, type=BOOL, align=left, ascii\_width=5 column=6, type=INFINITY, align=left, ascii\_width=8 column=7, type=NAN, align=left, ascii\_width=3 column=8, type=STRING, align=left, ascii\_width=24

Full example source code can be found at *examples/py/to\_column\_dp\_list.py*

# Dependencies

- Python 3.9+
- [Python package dependencies (automatically installed)](https://github.com/thombashi/DataProperty/network/dependencies)\_

## Optional dependencies

- [loguru](https://github.com/Delgan/loguru)\_
- Used for logging if the package installed

## **Details **

<dl>

<dt>Version</dt>
<dd>1.1.1</dd>

<dt>License</dt>
<dd>MIT License</dd>

<dt>Python</dt>
<dd>&gt;=3.9</dd>

<dt>Maintainer</dt>
<dd>Tsuyoshi Hombashi</dd></dl>

## **Links**

- [Changelog](https://github.com/thombashi/DataProperty/releases)
- [Homepage](https://github.com/thombashi/DataProperty)
- [Source](https://github.com/thombashi/DataProperty)
- [Tracker](https://github.com/thombashi/DataProperty/issues)
- [View on PyPI](https://pypi.org/project/DataProperty/)

## **Release Cadence **

**1**

releases in the past year

avg 25 days between releases

## **Maintainers **

- Tsuyoshi Hombashi · [tsuyoshi.hombashi@gmail.com](mailto:tsuyoshi.hombashi@gmail.com)

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://pypx.app/#website","@type":"WebSite","description":"The Python Package Index, reimagined. Fast search, dependency insights, download trends, and changelogs — all in one place.","name":"pypx","url":"https://pypx.app/"},{"@id":"https://pypx.app/packages/dataproperty#webpage","@type":"WebPage","description":"Python library for extract property from data.","name":"DataProperty","url":"https://pypx.app/packages/dataproperty","isPartOf":{"@id":"https://pypx.app/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://pypx.app/packages/dataproperty"]}]},{"@id":"https://pypx.app/packages/dataproperty#/schema/software-application/1","@type":"SoftwareApplication","applicationCategory":"DeveloperApplication","description":"Python library for extract property from data.","license":"MIT License","name":"DataProperty","softwareVersion":"1.1.1"}]}
```

## Sitemap

See the full [sitemap](https://pypx.app/sitemap.md) for all pages.
