index-align-ndarray
v1.0.4
Published
Get index aligned table from nx2 tables of different length
Downloads
9
Readme
index-align-ndarray
Given multiple nx2 ndarrays with a index column in ascending order, return a index aligned ndarray.
Good for aligning data based on dates, and the default behavior is to populate the new array's row if and only if there exists same index (data in first column) for all datasets provided.
e.g.
table1
10 1
12 3
15 4
20 1
table2
10 2
11 1
12 4
13 5
15 2
35 2
align([table1,table2]) ->
10 1 2
12 3 4
15 4 2
Usage
var ndarray = require('ndarray');
var align = require('index-align-ndarray');
var table1 = ndarray( new Float32Array([1,2,2,3,3,4,9,5]), [4,2], [2,1] );
var table2 = ndarray( new Float32Array([1,8,3,9,6,4,9,5]), [4,2], [2,1] );
var table3 = ndarray( new Float32Array([1,3,3,6,6,4,9,3]), [4,2], [2,1] );
var table4 = ndarray( new Float32Array([1,4,3,7,5,4,9,1]), [4,2], [2,1] );
var table5 = ndarray( new Float32Array([1,5,3,8,6,1,9,0]), [4,2], [2,1] );
var tables = [table1, table2, table3, table4, table5];
align( tables, function( err, data ) {
// do something with returned data
});
Limitations
2-D Tables only.