Angara.Table


Angara.Table (F#)

Angara.Table is a .NET library that provides types representing plain tables. It allows loading and saving tables and facilitates operations on tables.

A table is an immutable collection of named columns. Column values are represented as lazy one-dimensional immutable array of one of the supported types. Heights of all columns in a table are equal. Columns names are arbitrary strings; duplicate names are allowed but may cause ambiguity in some API functions.

Limiting the supported column types to relatively small types subset enables generic tools operating with tables, such as serialization services and visualization, to be able to handle all possible types.

Example

This example uses Angara.Table to create a table from numeric arrays and save the table as a CSV file:

1: 
2: 
3: 
4: 
5: 
6: 
open Angara.Data

let table = Table.OfColumns
                [ Column.Create ("x", [| for i in 0..99 -> float(i) / 10.0  |])
                  Column.Create ("sinx", [| for i in 0..99 -> sin (float(i) / 10.0) |]) ]
Table.Save(table, "table.csv")

The following example computes an average value of the column "sinx":

1: 
let sinAvrg = table.["sinx"].Rows.AsReal |> Seq.average

The next example views rows of the table as a sequence of the record instances:

1: 
2: 
type T = { x: float; sinx: float }
let rows : T seq = table.ToRows<T>()

Finally, this example loads a table from the CSV file and extends it with a new column built from another column:

1: 
2: 
3: 
let table2 = 
    Table.Load "table.csv" 
    |> Table.MapToColumn "logx" ["x"] log
seq
  [x[100]: float seq [0.0; 0.1; 0.2; 0.3; ...];
   sinx[100]: Array is not evaluated yet; logx[100]: Array is not evaluated yet]

How to get Angara.Table

The Angara.Table library can be installed from NuGet:
PM> Install-Package Angara.Table

Samples & Documentation

A table of Angara.Table is basically an immutable collection of named columns. The Table as Collection of Columns describes how to create a column and a table from a sequence of columns; how to add and remove columns; how to view column as an array of values and fetch an individual value from a table.

Sometimes it is necessary to view a table as a collection of rows. The Table as Collection of Rows describes how to get number of rows; how to get values of rows; how to represent table rows as a collection of typed objects.

The special case is a table having all columns of same type. The Table as Matrix describes how to create a matrix table and operate with it.

Angara.Table allows to save and load a table in the delimited text format (CSV). See Save and Load.

Angara.Table exposes a set of functions manipulating with Table that should make a code more succinct. These functions are described in Table Operations.

Contributing and copyright

The project is hosted on GitHub where you can report issues, fork the project and submit pull requests. If you're adding a new public API, please also consider adding samples that can be turned into a documentation. You might also want to read the library design notes to understand how it works.

The library is available under MIT license. For more information see the License file in the GitHub repository.

Fork me on GitHub