Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Danfo.js is an open source, JavaScript library providing high performance, intuitive, and easy to use data structures for manipulating and processing structured data.

License

NotificationsYou must be signed in to change notification settings

javascriptdata/danfojs

Repository files navigation



Danfojs: powerful javascript data analysis toolkit

Node.js CICoverage StatusTwitterPatreon donate button

What is it?

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

Main Features

  • Danfo.js is fast and supports Tensorflow.js tensors out of the box. This means you canconvert Danfo data structure to Tensors.
  • Easy handling ofmissing-data (represented asNaN) in floating point as well as non-floating point data
  • Size mutability: columns can beinserted/deleted from DataFrame
  • Automatic and explicitalignment: objects canbe explicitly aligned to a set of labels, or the user can simplyignore the labels and letSeries,DataFrame, etc. automaticallyalign the data for you in computations
  • Powerful, flexiblegroupby functionality to performsplit-apply-combine operations on data sets, for both aggregatingand transforming data
  • Make it easy to convert Arrays, JSONs, List or Objects, Tensors anddifferently-indexed data structuresinto DataFrame objects
  • Intelligent label-basedslicing,fancy indexing, andquerying oflarge data sets
  • Intuitivemerging andjoining datasets
  • Robust IO tools for loading data fromflat-files(CSV, Json, Excel).
  • Powerful, flexible and intutive API forplotting DataFrames and Series interactively.
  • Timeseries-specific functionality: date rangegeneration and date and time properties.
  • Robust data preprocessing functions likeOneHotEncoders,LabelEncoders, and scalers likeStandardScaler andMinMaxScaler are supported on DataFrame and Series

Installation

There are three ways to install and use Danfo.js in your application

  • For Nodejs applications, you can install thedanfojs-node version via package managers like yarn and/or npm:
npm install danfojs-nodeoryarn add danfojs-node

For client-side applications built with frameworks like React, Vue, Next.js, etc, you can install thedanfojs version:

npm install danfojsoryarn add danfojs

For use directly in HTML files, you can add the latest script tag fromJsDelivr to your HTML file:

<scriptsrc="https://cdn.jsdelivr.net/npm/danfojs@1.1.2/lib/bundle.js"></script>

See all available versionshere

Quick Examples

Example Usage in the Browser

<!DOCTYPE html><htmllang="en"><head><metacharset="UTF-8"/><metaname="viewport"content="width=device-width, initial-scale=1.0"/><scriptsrc="https://cdn.jsdelivr.net/npm/danfojs@1.1.2/lib/bundle.js"></script><title>Document</title></head><body><divid="div1"></div><divid="div2"></div><divid="div3"></div><script>dfd.readCSV("https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv").then(df=>{df['AAPL.Open'].plot("div1").box()//makes a box plotdf.plot("div2").table()//display csv as tablenew_df=df.setIndex({column:"Date",drop:true});//resets the index to Date columnnew_df.head().print()//new_df.plot("div3").line({config:{columns:["AAPL.Open","AAPL.High"]}})//makes a timeseries plot}).catch(err=>{console.log(err);})</script></body></html>

Output in Browser:

Example usage in Nodejs

constdfd=require("danfojs-node");constfile_url="https://web.stanford.edu/class/archive/cs/cs109/cs109.1166/stuff/titanic.csv";dfd.readCSV(file_url).then((df)=>{//prints the first five columnsdf.head().print();// Calculate descriptive statistics for all numerical columnsdf.describe().print();//prints the shape of the dataconsole.log(df.shape);//prints all column namesconsole.log(df.columns);// //prints the inferred dtypes of each columndf.ctypes.print();//selecting a column by subsettingdf["Name"].print();//drop columns by namesletcols_2_remove=["Age","Pclass"];letdf_drop=df.drop({columns:cols_2_remove,axis:1});df_drop.print();//select columns by dtypesletstr_cols=df_drop.selectDtypes(["string"]);letnum_cols=df_drop.selectDtypes(["int32","float32"]);str_cols.print();num_cols.print();//add new column to Dataframeletnew_vals=df["Fare"].round(1);df_drop.addColumn("fare_round",new_vals,{inplace:true});df_drop.print();df_drop["fare_round"].round(2).print(5);//prints the number of occurence each value in the columndf_drop["Survived"].valueCounts().print();//print the last ten elementa of a DataFramedf_drop.tail(10).print();//prints the number of missing values in a DataFramedf_drop.isNa().sum().print();}).catch((err)=>{console.log(err);});

Output in Node Console:

Notebook support

  • VsCode nodejs notebook extension now supports Danfo.js. See guidehere
  • ObservableHQ Notebooks. See example notebookhere

Documentation

The official documentation can be foundhere

Discussion and Development

Development discussions take placehere.

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 thecontributing guide.

LicenceMIT

About

Danfo.js is an open source, JavaScript library providing high performance, intuitive, and easy to use data structures for manipulating and processing structured data.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project

    Packages

    No packages published

    Contributors40


    [8]ページ先頭

    ©2009-2025 Movatter.jp