Python library for extract property from data.
Project Links
Meta
Author: Tsuyoshi Hombashi
Maintainer: Tsuyoshi Hombashi
Requires Python: >=3.9
Classifiers
Development Status
- 5 - Production/Stable
Intended Audience
- Developers
- Information Technology
License
- OSI Approved :: MIT License
Operating System
- OS Independent
Programming Language
- Python :: 3
- Python :: 3.9
- Python :: 3.10
- Python :: 3.11
- Python :: 3.12
- Python :: 3.13
- Python :: Implementation :: CPython
- Python :: Implementation :: PyPy
Topic
- Software Development :: Libraries
- Software Development :: Libraries :: Python Modules
Typing
- Typed
Summary
A Python library for extract property from data.
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
>>> 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
>>> 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
>>> 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
>>> 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
>>> 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
>>> 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:
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:
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
Optional dependencies
- loguru
Used for logging if the package installed
1.1.0
Dec 31, 2024
1.0.2
Dec 31, 2024
1.0.1
Jul 16, 2023
1.0.0
Jun 25, 2023
0.55.1
May 04, 2023
0.55.0
Mar 20, 2022
0.54.2
Oct 17, 2021
0.54.1
Oct 02, 2021
0.54.0
Oct 02, 2021
0.53.0
Sep 19, 2021
0.52.0
Jul 18, 2021
0.51.0
Jul 17, 2021
0.50.1
Mar 20, 2021
0.50.0
Aug 03, 2020
0.49.1
May 10, 2020
0.49.0
May 05, 2020
0.48.3
May 04, 2020
0.48.2
Apr 23, 2020
0.48.1
Apr 15, 2020
0.48.0
Apr 15, 2020
0.47.0
Mar 29, 2020
0.46.4
Feb 16, 2020
0.46.3
Feb 14, 2020
0.46.2
Feb 11, 2020
0.46.1
Feb 09, 2020
0.46.0
Feb 09, 2020
0.45.0
Feb 05, 2020
0.44.0
Feb 05, 2020
0.43.3
Jan 12, 2020
0.43.2
Jan 05, 2020
0.43.1
May 11, 2019
0.43.0
May 02, 2019
0.42.4
Apr 30, 2019
0.42.3
Apr 30, 2019
0.42.2
Apr 20, 2019
0.42.1
Mar 03, 2019
0.42.0
Feb 11, 2019
0.41.0
Feb 03, 2019
0.40.0
Jan 27, 2019
0.39.3
Jan 27, 2019
0.39.2
Jan 26, 2019
0.39.1
Jan 19, 2019
0.39.0
Jan 18, 2019
0.38.1
Jan 12, 2019
0.38.0
Jan 07, 2019
0.37.1
Jan 03, 2019
0.37.0
Jan 01, 2019
0.36.1
Dec 30, 2018
0.36.0
Nov 25, 2018
0.35.2
Oct 31, 2018
0.35.1
Oct 30, 2018
0.35.0
Oct 13, 2018
0.34.0
Oct 07, 2018
0.33.1
Oct 07, 2018
0.33.0
Sep 30, 2018
0.32.0
Sep 24, 2018
0.31.2
Aug 04, 2018
0.31.1
Jun 30, 2018
0.31.0
Jun 09, 2018
0.30.7
Jun 03, 2018
0.30.6
May 12, 2018
0.30.5
May 12, 2018
0.30.4
May 05, 2018
0.30.3
Apr 29, 2018
0.30.2
Apr 22, 2018
0.30.1
Apr 22, 2018
0.30.0
Jan 01, 2018
0.29.1
Nov 19, 2017
0.29.0
Nov 19, 2017
0.28.0
Nov 12, 2017
0.27.0
Nov 11, 2017
0.26.1
Nov 04, 2017
0.26.0
Nov 04, 2017
0.25.6
Aug 16, 2017
0.25.5
Aug 15, 2017
0.25.4
Jul 31, 2017
0.25.3
Jul 31, 2017
0.25.2
Jul 31, 2017
0.25.1
Jul 22, 2017
0.25.0
Jul 15, 2017
0.24.4
Jun 29, 2017
0.24.3
Jun 27, 2017
0.24.2
Jun 25, 2017
0.24.1
Jun 25, 2017
0.24.0
Jun 24, 2017
0.23.0
May 28, 2017
0.22.0
May 14, 2017
0.21.1
May 07, 2017
0.21.0
May 05, 2017
0.20.4
May 04, 2017
0.20.3
May 04, 2017
0.20.2
May 02, 2017
0.20.1
May 01, 2017
0.20.0
Apr 29, 2017
0.19.0
Apr 28, 2017
0.18.1
Apr 23, 2017
0.18.0
Apr 23, 2017
0.17.0
Feb 27, 2017
0.16.2
Jan 09, 2017
0.16.1
Jan 09, 2017
0.16.0
Jan 08, 2017
0.15.2
Jan 02, 2017
0.15.1
Dec 31, 2016
0.15.0
Dec 31, 2016
0.14.0
Dec 30, 2016
0.13.9
Dec 28, 2016
0.13.8
Dec 25, 2016
0.13.7
Dec 24, 2016
0.13.6
Dec 18, 2016
0.13.5
Dec 10, 2016
0.13.3
Nov 27, 2016
0.13.2
Nov 26, 2016
0.13.1
Nov 26, 2016
0.13.0
Nov 20, 2016
0.12.0
Nov 06, 2016
0.11.2
Nov 05, 2016
0.11.1
Nov 05, 2016
0.11.0
Nov 05, 2016
0.10.1
Oct 30, 2016
0.10.0
Oct 16, 2016
0.9.0
Sep 10, 2016
0.8.1
Jul 27, 2016
0.8.0
Jul 23, 2016
0.7.2
Jul 17, 2016
0.7.1
Jul 10, 2016
0.7.0
Jul 09, 2016
0.6.0
Jul 09, 2016
0.5.4
Jul 04, 2016
0.5.3
Jul 03, 2016
0.5.2
Jul 03, 2016
0.5.1
Jul 03, 2016
0.5.0
Jul 03, 2016
0.4.1
Jul 02, 2016
0.4.0
Jul 02, 2016
0.3.1
Jun 10, 2016
0.3.0
Jun 04, 2016
0.2.9
May 29, 2016
0.2.8
May 15, 2016
0.2.7
May 14, 2016
0.2.6
Apr 09, 2016
0.2.5
Mar 24, 2016
0.2.4
Mar 21, 2016
0.2.3
Mar 21, 2016
0.2.2
Mar 20, 2016
0.2.1
Mar 11, 2016
0.2.0
Mar 08, 2016
0.1.0
Feb 20, 2016