How to use the data-forge.DataFrame function in data-forge

To help you get started, we’ve selected a few data-forge examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SockTrader / SockTrader / src / __tests__ / data / candleNormalizer.spec.ts View on Github external
function createDataFrame() {
    // @formatter:off
    return new DataFrame([
        {high: 5663.99, low: 5639.25, open: 5658.11, close: 5647.88, volume: 0.67, timestamp: moment("2019-05-06T10:00:00.000Z")},
        {high: 5660, low: 5608.04, open: 5627.37, close: 5658.11, volume: 10.623, timestamp: moment("2019-05-06T02:00:00.000Z")},
        {high: 5638, low: 5613.12, open: 5621.01, close: 5627.3766, volume: 20, timestamp: moment("2019-05-06T01:00:00.000Z")},
    ]);
    // @formatter:on
}
github data-forge / data-forge-plot / examples / example-10.ts View on Github external
async function main(): Promise {

    const df = new DataFrame({
            columns: {
                versicolor_x: versicolor_x,
                versicolor_y: versicolor_y,
                setosa_x: setosa_x,
                setosa_y: setosa_y,  
            },
        });
    
    //console.log(df.head(10).toString());
    
    const plot = df.plot()
        .chartType(ChartType.Scatter)
        .y()
            .addSeries("versicolor_y")
                .label("Versicolor")
                //todo: .color("blue")
github data-forge / data-forge-plot / examples / example-7.ts View on Github external
async function main(): Promise {

    const df = new DataFrame({
            columns: {
                versicolor_x: versicolor_x,
                versicolor_y: versicolor_y,
            },
        });
    
    //console.log(df.toString());
    
    const plot = df.plot({ chartType: ChartType.Scatter }, { x: "versicolor_x", y: "versicolor_y" });
    await plot.renderImage(path.join(outputPath, "image.png"), { openImage: false });
    await plot.exportWeb(path.join(outputPath, "web"), { overwrite: true, openBrowser: false });
}
github data-forge / data-forge-plot / examples / example-3.ts View on Github external
async function main(): Promise {

    const df = new DataFrame({
            columns: {
                date: x,
                data1: data1,
                data2: data2
            },
        })
        .parseDates("date", "YYYY-MM-DD");
    
    //console.log(df.toString());
    
    const plot = df.plot({}, { x: "date", y: [ "data1", "data2" ]});
    await plot.renderImage(path.join(outputPath, "image.png"), { openImage: false });
    await plot.exportWeb(path.join(outputPath, "web"), { overwrite: true, openBrowser: false });
}
github data-forge / data-forge-plot / examples / example-6.ts View on Github external
async function main(): Promise {

    const df = new DataFrame({
            columns: {
                data1: data1,
                data2: data2,
                data3: data3,
            },
        });
    
    //console.log(df.toString());
    
    const plot = df.plot()
        .chartType(ChartType.Bar);
    await plot.renderImage(path.join(outputPath, "image.png"), { openImage: false });
    await plot.exportWeb(path.join(outputPath, "web"), { overwrite: true, openBrowser: false });
}
github Grademark / grademark / src / lib / optimize.ts View on Github external
function bucket(optimizationIterationResults: IDataFrame, numBuckets: number, searchDirection: OptimizeSearchDirection): IDataFrame {

    if (optimizationIterationResults.none()) {
        return new DataFrame();
    }

    const totalValues = optimizationIterationResults.count();
    const parameterValues = optimizationIterationResults.deflate(iterationResult => iterationResult.parameterValue).bake();
    const min = parameterValues.min();
    const max = parameterValues.max();
    const range = max - min;
    return optimizationIterationResults
        .select(iterationResult => {
            const bucketIndex = Math.floor(((iterationResult.parameterValue - min) / range) * (numBuckets-1));
            return {
                bucketIndex: bucketIndex,
                iterationResult: iterationResult,
            };
        })
        .groupBy(bucket => bucket.bucketIndex)
github Grademark / grademark / src / lib / monte-carlo.ts View on Github external
if (numTrades === 0) {
        return new Series>();
    }

    const random = new MersenneTwister(0);
    const samples: IDataFrame[] = [];

    for (let iterationIndex = 0; iterationIndex < numIterations; ++iterationIndex) {
        const sample: ITrade[] = [];

        for (var tradeIndex = 0; tradeIndex < numSamples; ++tradeIndex) {
            var tradeCopyIndex = getRandomInt(random, 0, numTrades-1);
            sample.push(tradesArray[tradeCopyIndex]);
        }

        samples.push(new DataFrame(sample));
    }

    return new Series>(samples);
}

data-forge

JavaScript data transformation and analysis toolkit inspired by Pandas and LINQ.

MIT
Latest version published 9 months ago

Package Health Score

64 / 100
Full package analysis