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.
-
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
var series = new Series(['hello world']);
series instanceof Series // true
series instanceof Array // true
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
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.
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.
- 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.
Series Object
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.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);
- condition
- The data parameter