https://github.com/queryverse/datatables.jl
A simple read-only table type for the Queryverse
https://github.com/queryverse/datatables.jl
Last synced: 8 months ago
JSON representation
A simple read-only table type for the Queryverse
- Host: GitHub
- URL: https://github.com/queryverse/datatables.jl
- Owner: queryverse
- License: mit
- Created: 2019-11-11T19:04:56.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-08-22T16:53:29.000Z (almost 6 years ago)
- Last Synced: 2025-01-20T17:51:51.468Z (over 1 year ago)
- Language: Julia
- Homepage:
- Size: 199 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# DataTables.jl
[](https://www.repostatus.org/#wip)
[](https://travis-ci.com/queryverse/DataTables.jl)
[](https://codecov.io/gh/queryverse/DataTables.jl)
## Overview
A simple read-only table type for the [Queryverse](https://github.com/queryverse).
## Installation
You can install the package at the Pkg REPL-mode with:
```julia
pkg> add DataTables
```
## Getting started
The main type in this package is `DataTable`, a data structure for tabular data. To create a new `DataTable` with a number of columns, just pass the columns as keyword arguments to the `DataTable` constructor:
```julia
julia> dt = DataTable(Name=["John", "Sally", "Jim"], Age=[23., 43., 56.], Children=[2, 0, 3])
3x3 DataTable
Name │ Age │ Children
──────┼──────┼─────────
John │ 23.0 │ 2
Sally │ 43.0 │ 0
Jim │ 56.0 │ 3
```
To access an individual column by name, use the `.` dot syntax:
```julia
julia> dt.Age
3-element ReadOnlyArrays.ReadOnlyArray{Float64,1,Array{Float64,1}}:
23.0
43.0
56.0
```
To access an individual row, use the normal julia index syntax:
```julia
julia> dt[2]
(Name = "Sally", Age = 43.0, Children = 0)
```
If you want to access the value in an individual cell, it is generally more efficient to first access the column via the dot syntax, and then select the value for a given row via indexing:
```julia
julia> dt.Name[2]
"Sally"
```
You can also create a new `DataTable` by passing any object to its constructor that implements the [TableTraits.jl](https://github.com/queryverse/TableTraits.jl) interface. That includes everything in the [Queryverse](https://www.queryverse.org/), but also many other table types like [DataFrames.jl](https://github.com/JuliaData/DataFrames.jl), [IndexedTables.jl](https://github.com/JuliaComputing/IndexedTables.jl) etc. Every `DataTable` also implements the [TableTraits.jl](https://github.com/queryverse/TableTraits.jl) interface and can therefore be passed to any function that accepts a [TableTraits.jl](https://github.com/queryverse/TableTraits.jl) value.
## Alternatives
DataTables.jl is not the only julia initiative for tabular data, there are many other packages that have similar goals. Take a look at [DataFrames.jl](https://github.com/JuliaData/DataFrames.jl), [IndexedTables.jl](https://github.com/JuliaComputing/IndexedTables.jl) and [TypedTables.jl](https://github.com/JuliaData/TypedTables.jl) (which in particular was a major inspiration for this package here). If I missed other packages, please let me know and I'll add them to this list!
## Getting help
Please ask any usage question in the [Data Domain](https://discourse.julialang.org/c/domain/data) on the [julia Discourse forum](https://discourse.julialang.org/). If you find a bug or have an improvement suggestion for this package, please open an issue in this github repository.