Package Exports
- data-forge
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (data-forge) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Data-Forge
The JavaScript data transformation and analysis toolkit inspired by Pandas and LINQ.
Implemented in TypeScript, used in JavaScript ES5+ or TypeScript.
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.
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
- Node.js (npm install --save data-forge) (see example here)
- Browser
- Via bower (bower install --save data-forge) (see example here)
- Via Browserify (see example here)
- Via Webpack (see example here)