https://github.com/antononcube/raku-data-typesystem
Data type system for different data structures.
https://github.com/antononcube/raku-data-typesystem
data data-structures rakulang type-system
Last synced: 9 months ago
JSON representation
Data type system for different data structures.
- Host: GitHub
- URL: https://github.com/antononcube/raku-data-typesystem
- Owner: antononcube
- License: artistic-2.0
- Created: 2023-06-03T15:28:05.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-05-14T19:46:29.000Z (almost 2 years ago)
- Last Synced: 2025-02-08T11:13:08.033Z (about 1 year ago)
- Topics: data, data-structures, rakulang, type-system
- Language: Raku
- Homepage: https://raku.land/zef:antononcube/Data::TypeSystem
- Size: 36.1 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README-work.md
- License: LICENSE
Awesome Lists containing this project
README
# Raku Data::TypeSystem
[](https://opensource.org/licenses/Artistic-2.0)
This Raku package provides a type system for different data structures that are
coercible to full arrays. Its code was originally developed in
["Data::Reshapers"](https://github.com/antononcube/Raku-Data-Reshapers), [AAp1].
------
## Installation
From [Zef ecosystem](https://raku.land):
```
zef install Data::TypeSystem
```
From GitHub:
```
zef install https://github.com/antononcube/Raku-Data-TypeSystem.git
```
------
## 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:
```perl6
use Data::ExampleDatasets;
my $url = 'https://raw.githubusercontent.com/antononcube/Raku-Data-Reshapers/main/resources/dfTitanic.csv';
my @dsTitanic = example-dataset($url, headers => 'auto');
@dsTitanic = @dsTitanic.map({$_ = $_.Numeric; $_}).Array;
@dsTitanic.elems
```
Here is a sample of dataset's records:
```perl6
.say for @dsTitanic.pick(5)
```
Here is the type of a single record:
```perl6
use Data::TypeSystem;
deduce-type(@dsTitanic[12])
```
Here is the type of single record's values:
```perl6
deduce-type(@dsTitanic[12].values.List)
```
Here is the type of the whole dataset:
```perl6
deduce-type(@dsTitanic)
```
Here is the type of "values only" records:
```perl6
my @valArr = @dsTitanic>>.values>>.Array;
deduce-type(@valArr)
```
Here is the type of the string values only records:
```perl6
my @valArr = @dsTitanic.map({ $_.grep({ $_.value ~~ Str }).Hash })>>.values>>.Array;
.say for @valArr.pick(4);
```
```perl6
deduce-type(@valArr);
```
-------
## References
[AAp1] Anton Antonov,
[Data::Reshapers Raku package](https://github.com/antononcube/Raku-Data-Reshapers),
(2021),
[GitHub/antononcube](https://github.com/antononcube/).