Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
141 lines (102 sloc) 5.59 KB

Data-Forge

The JavaScript data transformation and analysis toolkit inspired by Pandas and LINQ.

Implemented in TypeScript, used in JavaScript ES5+ or TypeScript.

Need to plot charts? Check out my new API that goes hand-in-hand with Data-Forge.

Why not do your data wrangling, analysis and visualization entirely in JavaScript? To support my effort please buy or help promote my book Data Wrangling with JavaScript.

Or check out my blog: The Data Wrangler.

Do your prototyping and exploratory data analysis in JavaScript with Data-Forge Notebook.

Build Status Coverage Status npm version GitHub license GitHub issues

Please note that this repository replaces the old version of Data-Forge.

Install

npm install --save data-forge

Quick start

Data-Forge can load CSV, JSON or arbitrary data sets.

Parse the data, filter it, transform it, aggregate it, sort it and much more.

Use the data however you want or export it to CSV or JSON.

Here's an example:

const dataForge = require('data-forge');
dataForge.readFile('./input-data-file.csv') // Read CSV file (or JSON!)
    .parseCSV()
    .parseDates(["Column B"]) // Parse date columns.
    .parseInts(["Column B", "Column C"]) // Parse integer columsn.
    .parseFloats(["Column D", "Column E"]) // Parse float columns.
    .dropSeries(["Column F"]) // Drop certain columns.
    .where(row => predicate(row)) // Filter rows.
    .select(row => transform(row)) // Transform the data.
    .asCSV() 
    .writeFile("./output-data-file.csv") // Write to output CSV file (or JSON!)
    .then(() => {
        console.log("Done!");
    })
    .catch(err => {
        console.log("An error occurred!");
    });

From the browser

Data-Forge also works in the browser (just don't try call readFile, etc - some functions only work under Node.js).

Install

Install via Bower (you can also use Browserify or Webpack, see below).

bower install --save data-forge

Include

Include the code in your HTML

<script language="javascript" type="text/javascript" src="bower_components/data-forge/data-forge.js"></script>

Use

Use it via the dataForge global variable.

var myDataframe = new dataForge.DataFrame(... your data here ...);

Features

  • Import and export CSV and JSON data and text files.
  • Also work with arbitrary JavaScript data.
  • Many options for working with your data:
    • Filtering
    • Transformation
    • Extracting subsets
    • Grouping, aggregation and summarization
    • Sorting
    • And much more
  • Great for slicing and dicing tabular data:
    • Add, remove, transform and generate named columns (series) of data.
  • Great for working with time series data.
  • Your data is indexed so you have the ability to merge and aggregate.
  • Your data is immutable! Transformations and modifications produce a new dataset.
  • Build data pipeline that are evaluated lazily.
  • Inspired by Pandas and LINQ, so it might feel familiar!

Platforms

Documentation

Resources