dataframe
Explore data by grouping and reducing.
Last updated 4 years ago by dguttman .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install dataframe 
SYNC missed versions from official npm registry.

DataFrame

Explore data by grouping and reducing.

Example


var DataFrame = require('..')

var data = require('./data.json')

var dimensions = [
  {value: 'firstName', title: 'First Name'},
  {value: 'lastName', title: 'Last Name'},
  {value: 'state', title: 'State'},
  {value: function(row) {
    return row.transaction.business
  }, title: 'Business'},
  {value: function(row) {
    return row.transaction.type
  }, title: 'Transaction Type'}
]

var reduce = function(row, memo) {
  memo.count = (memo.count || 0) + 1
  memo.amountTotal = (memo.amountTotal || 0) + parseFloat(row.transaction.amount)
  return memo
}

var df = DataFrame({
  rows: data,
  dimensions: dimensions,
  reduce: reduce
})

var results = df.calculate({
  dimensions: ['First Name', 'Last Name'],
  sortBy: 'amountTotal',
  sortDir: 'desc',
  // optionally filter results based on dimension values
  filter: function(dimensions) {
    return dimensions['First Name'] === 'Maximilian'
  }
})

console.log('results', results)

License

MIT

Current Tags

  • 2.0.1                                ...           latest (4 years ago)

15 Versions

  • 2.0.1                                ...           4 years ago
  • 2.0.0                                ...           4 years ago
  • 1.5.0                                ...           4 years ago
  • 1.4.0                                ...           4 years ago
  • 1.3.0                                ...           5 years ago
  • 1.2.3                                ...           6 years ago
  • 1.2.2                                ...           6 years ago
  • 1.2.1                                ...           6 years ago
  • 1.2.0                                ...           6 years ago
  • 1.1.1                                ...           6 years ago
  • 1.1.0                                ...           6 years ago
  • 1.0.2                                ...           6 years ago
  • 1.0.1                                ...           6 years ago
  • 1.0.0                                ...           6 years ago
  • 0.0.0                                ...           8 years ago
Maintainers (1)
Downloads
Today 0
This Week 2
This Month 6
Last Day 1
Last Week 1
Last Month 6
Dependencies (1)
Dev Dependencies (2)

Copyright 2014 - 2017 © taobao.org |