oafbot / Series

series data processing & manipulation for js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Series.js

Data processing and manipulation tools for Javascript.

The Series object class extends the Array prototype. It inherits all the native Array methods, while providing some additional functionality that may be found in other data processing tools such as python pandas, R, and SQL.


Usage

Contents:
  1. Creating a Series object

  2. Data formats

  3. Static Methods
    .from
    .export
    .json

  4. Series Properties
    .col
    .count
    .delete
    .left
    .right

  5. Series Object Methods
    .all
    .avg
    .clone
    .column
    .columns
    .deepcopy
    .diff
    .duplicates
    .equal
    .fillin
    .get
    .groupby
    .has
    .intersect
    .numeric
    .last
    .limit
    .max
    .merge
    .min
    .null
    .orderby
    .partly
    .range
    .rename
    .resolve
    .row
    .segment
    .select
    .show
    .shuffle
    .sum
    .top
    .typeof
    .unique
    .where



Creating a Series Object

var series = new Series(['hello world']);

series instanceof Series // true
series instanceof Array  // true


Data Formats

The Series object can accept multi-dimentional data in the following three formats and their respective json string represenations. The Series object natively represents data as an array of objects, where the object keys stand in for the columns found in a tabluar data format.

Therefore, the following tabular data

alt text

would be represented as:

[
    { "id": 0, "name": "bonk",    "species": "dog", "skill": "bark" },
    { "id": 1, "name": "mittens", "species": "cat", "skill": "meow" }
]

The same dataset can be described as an object with columns and rows properties.

{
    "columns" : [ "id", "name", "species", "skill" ],
    "rows"    : [
        [0, "bonk", "dog", "bark"],
        [1, "mittens", "cat", "meow"]
    ]
}

Or as a multidimentional array, where the first row represents the column names.

[
    ["id", "name", "species", "skill"]
    [0, "bonk", "dog", "bark"]
    [1, "mittens", "cat", "meow"]
]

The first format can be directly fed into a new Series() call. The three formats, their json string representations, flat arrays, and csv files can be fed into the static method Series.from() to create a Series object instance.


Static Methods

Series.from( data, name )

var data, animals, data1;

data = [
    { "id": 0, "name": "bonk",    "species": "dog", "skill":"bark" },
    { "id": 1, "name": "mittens", "species": "cat", "skill":"meow" }
];

animals = Series.from(data);

/* or when loading from an external source... */
Series.from('data/data1.json', 'data1');

The Series.from method will take a javascript object, json string, or an external resource, and create a new instance of a Series object.

Parameters:
data
The < data > parameter can be of type object, array, or string (see section on formats). When loading a dataset from an external source, this parameter should be a string representing the file path or url for the resource.
name
The < name > parameter is only required if an external resource is requested. Once parsed, the data will be assigned to a variable with the name provided.
Returns:

Series Object


Series.export( series, format )

var animals, exported;

animals = [
    { "id": 0, "name": "bonk",    "species": "dog", "skill":"bark" },
    { "id": 1, "name": "mittens", "species": "cat", "skill":"meow" }
];

exported = Series.export(animals, 'json');  /* output formats: object, array, json, csv */

Series.json

Series.json.load( url, assignment )

var animals;

animals = Series.json.load('http://example.com/zoo/animals.json');

Series.json.dump( series )

var animals, json;

animals = [
    { "id": 0, "name": "bonk",    "species": "dog", "skill":"bark" },
    { "id": 1, "name": "mittens", "species": "cat", "skill":"meow" }
];

json = Series.json.dump(animals);




Series Object Properties

Series.prototype.col

Series.prototype.count

Series.prototype.delete

Series.prototype.delete.column( )
Series.prototype.delete.row( )

Series.prototype.delete.index( )

Series.prototype.delete.where( )

Series.prototype.left

Series.prototype.left.merge( )

Series.prototype.right

Series.prototype.right.merge( )




Series Object Methods

Series.prototype.all( condition )

condition
The data parameter


Series.prototype.avg( column )




Series.prototype.clone( )


Series.prototype.column( name )




Series.prototype.columns( order )




Series.prototype.deepcopy( )




Series.prototype.diff( )




Series.prototype.duplices( )




Series.prototype.equal( )




Series.prototype.fill( )




Series.prototype.get( )




Series.prototype.group( )




Series.prototype.has( )




Series.prototype.intersect( )




Series.prototype.numeric( )




Series.prototype.last( )




Series.prototype.limit( )




Series.prototype.max( )




Series.prototype.merge( )




Series.prototype.min( )




Series.prototype.null( )




Series.prototype.orderby( )




Series.prototype.partly( )




Series.prototype.range( )




Series.prototype.rename( )




Series.prototype.resolve( )




Series.prototype.row( )




Series.prototype.segment( )




Series.prototype.select( )




Series.prototype.show( )




Series.prototype.shuffle( )




Series.prototype.sum( )




Series.prototype.top( )




Series.prototype.typeof( )




Series.prototype.unique( )




Series.prototype.where( )





About

series data processing & manipulation for js


Languages

Language:JavaScript 96.8%Language:HTML 3.2%