Skip to main content

DataTypeSystem

This Python package provides a type system for different data structures that are coercible to full arrays. It is Python translation of the code of the Raku package "Data::TypeSystem", [AAp1].


Installation

Install from GitHub

pip install -e git+https://github.com/antononcube/Python-packages.git#egg=DataTypeSystem-antononcube\&subdirectory=DataTypeSystem

From PyPi

pip install DataTypeSystem

Usage examples

The type system conventions follow those of Mathematica's Dataset -- see the presentation "Dataset improvements".

Here we get the Titanic dataset, change the "passengerAge" column values to be numeric, and show dataset's dimensions:

import pandas

dfTitanic = pandas.read_csv('https://raw.githubusercontent.com/mwaskom/seaborn-data/master/titanic.csv')
dfTitanic = dfTitanic[["sex", "age", "pclass", "survived"]]
dfTitanic = dfTitanic.rename(columns ={"pclass": "class"})
dfTitanic.shape
(891, 4)

Here is a sample of dataset's records:

from DataTypeSystem import *

dfTitanic.sample(3)
sex age class survived
555 male 62.0 1 0
278 male 7.0 3 0
266 male 16.0 3 0

Here is the type of a single record:

deduce_type(dfTitanic.iloc[12].to_dict())
Struct([age, class, sex, survived], [float, int, str, int])

Here is the type of single record's values:

deduce_type(dfTitanic.iloc[12].to_dict().values())
Tuple([Atom(<class 'str'>), Atom(<class 'float'>), Atom(<class 'int'>), Atom(<class 'int'>)])

Here is the type of the whole dataset:

deduce_type(dfTitanic.to_dict())
Assoc(Atom(<class 'str'>), Assoc(Atom(<class 'int'>), Atom(<class 'str'>), 891), 4)

Here is the type of "values only" records:

valArr = dfTitanic.transpose().to_dict().values()
deduce_type(valArr)
Vector(Struct([age, class, sex, survived], [float, int, str, int]), 891)

References

[AAp1] Anton Antonov, Data::TypeSystem Raku package, (2023), GitHub/antononcube.

Release files for DataTypeSystem 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for DataTypeSystem 0.1.1
File Size Uploaded
DataTypeSystem-0.1.1.tar.gz 6.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for DataTypeSystem 0.1.1
File Interpreter ABI Platform
DataTypeSystem-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 13.0 kB

Release files / DataTypeSystem-0.1.1.tar.gz

Download URL DataTypeSystem-0.1.1.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
dcb369c4fbd0c7439da4a3ca9a6b1c832f6f0c816adeec5933a4661dc5aeea4a
BLAKE2b-256 checksum
How to use checksums
ed1d9a6d19411a7604ea50239e0ef277d4542add6bed080e40a5cdd5615d2c0e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.8

Release files / DataTypeSystem-0.1.1-py3-none-any.whl

Download URL DataTypeSystem-0.1.1-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8394173daaee087b8b0782e1c2bd7784e18eef47b7c6d457902f0da947eff93b
BLAKE2b-256 checksum
How to use checksums
c1971c23cca8b7ea88724ff30ff77bfa3424ded8cc61eb90e58eb0be3cd9ba3e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.8

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page