TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Danfojs: powerful javascript data analysis toolkit

Node.js CI Coverage Status Twitter Patreon donate button

What is it?

Danfo.js is a javascript package that provides fast, flexible, and expressive data structures designed to make working with "relational" or "labeled" data both easy and intuitive. It is heavily inspired by Pandas library, and provides a similar API. This means that users familiar with Pandas, can easily pick up danfo.js.

Main Features

  • Danfo.js is fast. It is built on Tensorflow.js, and supports tensors out of the box. This means you can convert Danfo data structure to Tensors.
  • Easy handling of missing-data (represented as NaN) in floating point as well as non-floating point data
  • Size mutability: columns can be inserted/deleted from DataFrame
  • Automatic and explicit alignment: objects can be explicitly aligned to a set of labels, or the user can simply ignore the labels and let Series, DataFrame, etc. automatically align the data for you in computations
  • Powerful, flexible groupby functionality to perform split-apply-combine operations on data sets, for both aggregating and transforming data
  • Make it easy to convert Arrays, JSONs, List or Objects, Tensors and differently-indexed data structures into DataFrame objects
  • Intelligent label-based slicing, fancy indexing, and querying of large data sets
  • Intuitive merging and joining data sets
  • Robust IO tools for loading data from flat-files (CSV, Json, Excel, Data package).
  • Powerful, flexible and intutive API for plotting DataFrames and Series interactively.
  • Timeseries-specific functionality: date range generation and date and time properties.
  • Robust data preprocessing functions like OneHotEncoders, LabelEncoders, and scalers like StandardScaler and MinMaxScaler are supported on DataFrame and Series

To use Danfo.js via script tags, copy and paste the CDN below to the body of your HTML file

    <script src="https://cdn.jsdelivr.net/npm/danfojs@0.2.3/lib/bundle.min.js"></script> 

Example Usage in the Browser

See the example below in Code Sandbox

<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://cdn.plot.ly/plotly-1.2.0.min.js"></script> 
    <script src="https://cdn.jsdelivr.net/npm/danfojs@0.2.3/lib/bundle.min.js"></script> 



    <div id="div1"></div>
    <div id="div2"></div>
    <div id="div3"></div>


            .then(df => {

                df['AAPL.Open'].plot("div1").box() //makes a box plot

                df.plot("div2").table() //display csv as table

                new_df = df.set_index({ key: "Date" }) //resets the index to Date column
                new_df.plot("div3").line({ columns: ["AAPL.Open", "AAPL.High"] })  //makes a timeseries plot

            }).catch(err => {



Output in Browser:

How to install

Danfo.js is hosted on NPM, and can installed via package managers like npm and yarn

npm install danfojs-node

Example usage in Nodejs

const dfd = require("danfojs-node")

  .then(df => {
    //prints the first five columns

    //Calculate descriptive statistics for all numerical columns

    //prints the shape of the data

    //prints all column names

    //prints the inferred dtypes of each column

    //selecting a column by subsetting

    //drop columns by names
    cols_2_remove = ['Age', 'Pclass']
    df_drop = df.drop({ columns: cols_2_remove, axis: 1 })

    //select columns by dtypes
    let str_cols = df_drop.select_dtypes(["string"])
    let num_cols = df_drop.select_dtypes(["int32", "float32"])

    //add new column to Dataframe
    let new_vals = df['Fare'].round().values
    df_drop.addColumn({ column: "fare_round", value:  new_vals})


    //prints the number of occurence each value in the column

    //print the last ten elementa of a DataFrame

    //prints the number of missing values in a DataFrame

  }).catch(err => {

Output in Node Console:

If you want to use Danfo in frontend frameworks like React/Vue, read this guide

You can play with Danfo.js on Dnotebooks playground here

See the Official Getting Started Guide


The official documentation can be found here

Discussion and Development

Development discussions take place on our issues tab.

Contributing to Danfo

All contributions, bug reports, bug fixes, documentation improvements, enhancements, and ideas are welcome. A detailed overview on how to contribute can be found in the contributing guide.

Licence MIT

Created by Rising Odegua and Stephen Oni

Danfo.js - Open Source JavaScript library for manipulating data. | Product Hunt Embed


npm i danfo-js-baamtu

DownloadsWeekly Downloads






Unpacked Size

11.6 MB

Total Files


Last publish


  • leeaboubakary