Code Monkey home page Code Monkey logo

data-table's Introduction

data-table

[Experimental] A promise API for data wrangling in JavaScript

This repository is no longer in active development

Validate

isDataTable

[*] => promise<boolean>

Evaluates to true if the following are satisfied:

  • the argument is an object or promise resolving to an object
  • the object is not empty (i.e., has at least one key)
  • the value of every key is an array (may contain any data type)
  • arrays are of equal length

Describe

size

promise<dataTable> => promise<object>

Given a data table, returns a promise for an object containing the following key-value pairs:

  • variables: the number of variables (arrays) in the data table
  • observations: the number of observations (array length) for each variable

variables

promise<dataTable> => promise<array<string>>

Given a data table, returns a promise for an array of variable names.

values

promise<dataTable>, string => promise<array>

Given a data table and a variable name, returns a promise for an array containing the variable's observed values.

index

promise<dataTable>, number:int => promise<object>

Given a data table and a valid index, returns a promise for an object containing the value of each variable at that index, which represents a single observation across all variables in the data set.

head

promise<dataTable>, [number:int] => promise<dataTable>

Given a data table and an optional output size n (defaults to 5), returns a promise for a data table containing only the first n observations.

Functional Transforms

apply

promise<dataTable>, function<dataTable, ...[*] => *>, ...[*] => promise<*>

Apply an arbitrary function on a data table, returning a promise for the result.

apply2

promise<dataTable>, promise<dataTable>, function<dataTable, dataTable, ...[*] => *>, ...[*] => promise<*>

Apply an arbitrary function on two data tables, returning a promise for the result.

mapVars

promise<dataTable>, array<string>, function<array, ...[*] => array>, ...[*] => promise<dataTable>

Apply an arbitrary function on one or more variable arrays in a data table, returning a promise for a new data table with the resulting arrays.

mapValues

promise<dataTable>, array<string>, function<*, ...[*] => *>, ...[*] => promise<dataTable>

Apply an arbitrary function on every observed value for one or more variable arrays in a data table, returning a promise for a new data table with the resulting values.

Combine/Split

assign

promise<dataTable>, promise<dataTable> => promise<dataTable>

Assign the variables of two source data tables to a new target (analogous to Object.assign({}, a, b)). The two source data tables must have the same number of observations. If variable names are shared between the sources, the second overwrites the first. Returns a promise for the new combined data table.

select

promise<dataTable>, array<string> => promise<dataTable>

Given a data table and an array of variable names, returns a promise for a data table containing only the selected variables.

filter

promise<dataTable>, function<object, [number:int], [dataTable] => boolean> => promise<dataTable>

Given a data table and a filtering function, returns a promise for a data table filtered according the return values of the function, where true means keep and false means drop. The filtering function's first parameter is an object containing the value of each variable at index i, the second (optional) parameter is the value of i, and the third (optional) parameter is the data table being filtered. Analogous to Array.prototype.filter.

sample

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.