Advanced Usage

Module creation

Each module is a class with a constructor taking dataframe as parameter, and having a df and a name properties:

class FakeModule {
    constructor(dataframe) {
        this.df = dataframe; = 'fakemodule';

    test(x) {
        return this.df.withColumn('test', row => row.set('test', x * 2));

Module registration

You can register modules when you instantiate a DataFrame:

const df = new DataFrame(data, ['column1', 'column2', 'column3'], FakeModule, AnotherModule)
// You can call module by its name

// [SQL, Matrix, Stat, FakeModule, AnotherModule]

You can also set default modules:

DataFrame.setDefaultModules(FakeModule, Matrix);
const df = new DataFrame(data, ['column1', 'column2', 'column3'])

// [FakeModule, Matrix]

Reduce the bundle size

If you use webpack or other bundlers, and you only want the core of dataframe-js without additional modules (like sql, stat or other) you can use es6 imports in order to reduce your bundle size (

import DataFrame from 'dataframe-js/lib/dataframe';

results matching ""

    No results matching ""