Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
var dataForge = require('data-forge');
var E = require('linq');
//
// Create a simple data frame.
//
var values = E
.range(0, 14)
.select(function (i) {
return [i, Math.sin(i), Math.cos(i)];
})
.toArray();
var dataFrame = new dataForge.DataFrame({
columnNames: ["index", "Sin", "Cos"],
rows: values
})
.setIndex("index")
.dropSeries("index");
console.log(dataFrame.skip(4).take(5).toString());
var series = dataFrame.getSeries("Sin");
'use strict';
var dataForge = require('../../index.js');
var E = require('linq');
//
// Create a simple data frame.
//
var values = E
.range(0, 14)
.select(function (i) {
return [i, Math.sin(i), Math.cos(i)];
})
.toArray();
var dataFrame = new dataForge.DataFrame({
columnNames: ["index", "Sin", "Cos"],
rows: values
})
.setIndex("index")
.dropSeries("index");
console.log(dataFrame.skip(4).take(5).toString());
var series = dataFrame.getSeries("Sin");
getIterator: function () {
return new ArrayIterator(E.range(0, self.toValues().length).toArray());
},
});
.select(function (column) {
var numValues = column.series.toArray().length;
//todo: broad-cast column
var newSeries = new Series({
values: E.range(0, numValues)
.select(function () {
return column.name
})
.toArray()
});
return column.series.detectValues().withSeries('Column', newSeries);
})
.toArray();
getIterator: function () { //todo: broad-cast index
return new ArrayIterator(E.range(0, self.toValues().length).toArray());
},
}),
.selectMany(function (data) {
var index = data[0];
var values = data[1];
return E.range(0, values.length)
.select(function (_) {
return index;
})
.toArray();
})
.toArray();
function () {
return E.range(0, self.getValues().length).toArray();
}
);
matrix: function (numColumns, numRows, start, increment) {
return new DataFrame({
columnNames: E.range(1, numColumns)
.select(function (columnNumber) {
return columnNumber.toString();
})
.toArray(),
values: function () {
var rowIndex = 0;
var nextValue = start;
var curRow = undefined;
return {
moveNext: function () {
if (rowIndex >= numRows) {
return false;
}
curRow = E.range(0, numColumns)
.selectMany(function (data) {
var index = data[0];
var values = data[1];
return E.range(0, values.length)
.select(function (_) {
return index;
})
.toArray();
})
.toArray();
moveNext: function () {
if (rowIndex >= numRows) {
return false;
}
curRow = E.range(0, numColumns)
.select(function (columnIndex) {
return nextValue + (columnIndex * increment);
})
.toArray();
nextValue += numColumns * increment;
++rowIndex;
return true;
},