DataTypeSystem


NameDataTypeSystem JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://github.com/antononcube/Python-packages/tree/main/DataTypeSystem
SummaryData type system for different data structures (arrays, lists of dictionaries, etc.).
upload_time2023-10-04 11:50:54
maintainer
docs_urlNone
authorAnton Antonov
requires_python>=3.7
license
keywords data structure type system types
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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"](https://raku.land/zef:antononcube/Data::TypeSystem), [AAp1].

------

## Installation

### Install from GitHub

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

### From PyPi

```shell
pip install DataTypeSystem
```

------

## Usage examples

The type system conventions follow those of Mathematica's 
[`Dataset`](https://reference.wolfram.com/language/ref/Dataset.html) 
-- see the presentation 
["Dataset improvements"](https://www.wolfram.com/broadcast/video.php?c=488&p=4&disp=list&v=3264).

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


```python
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:


```python
from DataTypeSystem import *

dfTitanic.sample(3)
```




<div>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>sex</th>
      <th>age</th>
      <th>class</th>
      <th>survived</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>555</th>
      <td>male</td>
      <td>62.0</td>
      <td>1</td>
      <td>0</td>
    </tr>
    <tr>
      <th>278</th>
      <td>male</td>
      <td>7.0</td>
      <td>3</td>
      <td>0</td>
    </tr>
    <tr>
      <th>266</th>
      <td>male</td>
      <td>16.0</td>
      <td>3</td>
      <td>0</td>
    </tr>
  </tbody>
</table>
</div>



Here is the type of a single record:


```python
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:


```python
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:


```python
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:


```python
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](https://github.com/antononcube/Raku-Data-TypeSystem),
(2023),
[GitHub/antononcube](https://github.com/antononcube/).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/antononcube/Python-packages/tree/main/DataTypeSystem",
    "name": "DataTypeSystem",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "data structure,type system,types",
    "author": "Anton Antonov",
    "author_email": "antononcube@posteo.net",
    "download_url": "https://files.pythonhosted.org/packages/ed/1d/9a6d19411a7604ea50239e0ef277d4542add6bed080e40a5cdd5615d2c0e/DataTypeSystem-0.1.1.tar.gz",
    "platform": null,
    "description": "# DataTypeSystem\n\nThis Python package provides a type system for different data structures that are \ncoercible to full arrays. It is Python translation of the code of the Raku package\n[\"Data::TypeSystem\"](https://raku.land/zef:antononcube/Data::TypeSystem), [AAp1].\n\n------\n\n## Installation\n\n### Install from GitHub\n\n```shell\npip install -e git+https://github.com/antononcube/Python-packages.git#egg=DataTypeSystem-antononcube\\&subdirectory=DataTypeSystem\n```\n\n### From PyPi\n\n```shell\npip install DataTypeSystem\n```\n\n------\n\n## Usage examples\n\nThe type system conventions follow those of Mathematica's \n[`Dataset`](https://reference.wolfram.com/language/ref/Dataset.html) \n-- see the presentation \n[\"Dataset improvements\"](https://www.wolfram.com/broadcast/video.php?c=488&p=4&disp=list&v=3264).\n\nHere we get the Titanic dataset, change the \"passengerAge\" column values to be numeric, \nand show dataset's dimensions:\n\n\n```python\nimport pandas\n\ndfTitanic = pandas.read_csv('https://raw.githubusercontent.com/mwaskom/seaborn-data/master/titanic.csv')\ndfTitanic = dfTitanic[[\"sex\", \"age\", \"pclass\", \"survived\"]]\ndfTitanic = dfTitanic.rename(columns ={\"pclass\": \"class\"})\ndfTitanic.shape\n```\n\n\n\n\n    (891, 4)\n\n\n\nHere is a sample of dataset's records:\n\n\n```python\nfrom DataTypeSystem import *\n\ndfTitanic.sample(3)\n```\n\n\n\n\n<div>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>sex</th>\n      <th>age</th>\n      <th>class</th>\n      <th>survived</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>555</th>\n      <td>male</td>\n      <td>62.0</td>\n      <td>1</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>278</th>\n      <td>male</td>\n      <td>7.0</td>\n      <td>3</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>266</th>\n      <td>male</td>\n      <td>16.0</td>\n      <td>3</td>\n      <td>0</td>\n    </tr>\n  </tbody>\n</table>\n</div>\n\n\n\nHere is the type of a single record:\n\n\n```python\ndeduce_type(dfTitanic.iloc[12].to_dict())\n```\n\n\n\n\n    Struct([age, class, sex, survived], [float, int, str, int])\n\n\n\nHere is the type of single record's values:\n\n\n```python\ndeduce_type(dfTitanic.iloc[12].to_dict().values())\n```\n\n\n\n\n    Tuple([Atom(<class 'str'>), Atom(<class 'float'>), Atom(<class 'int'>), Atom(<class 'int'>)])\n\n\n\nHere is the type of the whole dataset:\n\n\n```python\ndeduce_type(dfTitanic.to_dict())\n```\n\n\n\n\n    Assoc(Atom(<class 'str'>), Assoc(Atom(<class 'int'>), Atom(<class 'str'>), 891), 4)\n\n\n\nHere is the type of \"values only\" records:\n\n\n```python\nvalArr = dfTitanic.transpose().to_dict().values()\ndeduce_type(valArr)\n```\n\n\n\n\n    Vector(Struct([age, class, sex, survived], [float, int, str, int]), 891)\n\n\n\n-------\n\n## References\n\n[AAp1] Anton Antonov,\n[Data::TypeSystem Raku package](https://github.com/antononcube/Raku-Data-TypeSystem),\n(2023),\n[GitHub/antononcube](https://github.com/antononcube/).\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Data type system for different data structures (arrays, lists of dictionaries, etc.).",
    "version": "0.1.1",
    "project_urls": {
        "Homepage": "https://github.com/antononcube/Python-packages/tree/main/DataTypeSystem"
    },
    "split_keywords": [
        "data structure",
        "type system",
        "types"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c1971c23cca8b7ea88724ff30ff77bfa3424ded8cc61eb90e58eb0be3cd9ba3e",
                "md5": "5512c1f490fd390e9400f64f965be6f1",
                "sha256": "8394173daaee087b8b0782e1c2bd7784e18eef47b7c6d457902f0da947eff93b"
            },
            "downloads": -1,
            "filename": "DataTypeSystem-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5512c1f490fd390e9400f64f965be6f1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 7009,
            "upload_time": "2023-10-04T11:50:53",
            "upload_time_iso_8601": "2023-10-04T11:50:53.409054Z",
            "url": "https://files.pythonhosted.org/packages/c1/97/1c23cca8b7ea88724ff30ff77bfa3424ded8cc61eb90e58eb0be3cd9ba3e/DataTypeSystem-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ed1d9a6d19411a7604ea50239e0ef277d4542add6bed080e40a5cdd5615d2c0e",
                "md5": "2b15ff5acc038c875674e31e01f74a95",
                "sha256": "dcb369c4fbd0c7439da4a3ca9a6b1c832f6f0c816adeec5933a4661dc5aeea4a"
            },
            "downloads": -1,
            "filename": "DataTypeSystem-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "2b15ff5acc038c875674e31e01f74a95",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 6022,
            "upload_time": "2023-10-04T11:50:54",
            "upload_time_iso_8601": "2023-10-04T11:50:54.557193Z",
            "url": "https://files.pythonhosted.org/packages/ed/1d/9a6d19411a7604ea50239e0ef277d4542add6bed080e40a5cdd5615d2c0e/DataTypeSystem-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-04 11:50:54",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "antononcube",
    "github_project": "Python-packages",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "datatypesystem"
}
        
Elapsed time: 1.55227s