Name: datalib
Owner: Vega
Description: JavaScript data utility library.
Created: 2015-04-14 17:45:56.0
Updated: 2018-01-18 07:23:48.0
Pushed: 2018-01-16 22:56:04.0
Homepage: http://vega.github.io/datalib/
Size: 3205
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Datalib is a JavaScript data utility library. It provides facilities for data loading, type inference, common statistics, and string templates. While datalib was created to power Vega and related projects, it is also a standalone library useful for data-driven JavaScript applications on both the client (web browser) and server (e.g., node.js).
For documentation, see the datalib API Reference.
Datalib provides a set of utilities for working with data. These include:
Datalib can be used both server-side and client-side. For use in node.js,
simply npm install datalib
or include datalib as a dependency in your package.json file. For use on the client, install datalib via bower install datalib
or include datalib.min.js on your web page. The minified JS file is built using browserify (see below for details).
oad datalib.
dl = require('datalib');
oad and parse a CSV file. Datalib does type inference for you.
he result is an array of JavaScript objects with named values.
arsed dates are stored as UNIX timestamp values.
data = dl.csv('http://vega.github.io/datalib/data/stocks.csv');
how summary statistics for each column of the data table.
ole.log(dl.format.summary(data));
ompute mean and standard deviation by ticker symbol.
rollup = dl.groupby('symbol')
ummarize({'price': ['mean', 'stdev']})
xecute(data);
ole.log(dl.format.table(rollup));
ompute correlation measures between price and date.
ole.log(
.cor(data, 'price', 'date'), // Pearson product-moment correlation
.cor.rank(data, 'price', 'date'), // Spearman rank correlation
.cor.dist(data, 'price', 'date') // Distance correlation
ompute mutual information distance between years and binned price.
bin_price = dl.$bin(data, 'price'); // returns binned price values
year_date = dl.$year('date'); // returns year from date field
counts = dl.groupby(year_date, bin_price).count().execute(data);
ole.log(dl.mutual.dist(counts, 'bin_price', 'year_date', 'count'));
To use datalib in the browser, you need to build the datalib.js and datalib.min.js files. We assume that you have npm installed.
npm install
in the datalib folder to install dependencies.npm run build
. This will invoke browserify to bundle the source files into datalib.js, and then uglify-js to create the minified datalib.min.js.If you are using Webpack 1, you need to enable a JSON-loader. To do so, first npm install --save json-loader
, then add the loader to your webpack config:
dule: {
loaders: [{
test: /\.json$/,
loader: 'json-loader'
}]