
Product
Introducing GitHub Actions Scanning Support
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socketβs new workflow scanning support.
danfojs-node
Advanced tools
JavaScript library providing high performance, intuitive, and easy to use data structures for manipulating and processing structured data.
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.
NaN
) in floating point as well as non-floating point dataSeries
, DataFrame
, etc. automatically
align the data for you in computationsdanfo.js is hosted on NPM, and can installed via package managers like npm and yarn
npm install danfojs-node
const dfd = require("danfojs-node")
dfd.read_csv("https://web.stanford.edu/class/archive/cs/cs109/cs109.1166/stuff/titanic.csv")
.then(df => {
//prints the first five columns
df.head().print()
//Calculate descriptive statistics for all numerical columns
df.describe().print()
//prints the shape of the data
console.log(df.shape);
//prints all column names
console.log(df.column_names);
//prints the inferred dtypes of each column
df.ctypes.print()
//selecting a column by subsettiing
df['Name'].print()
//drop columns by names
cols_2_remove = ['Age', 'Pclass']
df_drop = df.drop({ columns: cols_2_remove, axis: 1 })
df_drop.print()
//select columns by dtypes
let str_cols = df_drop.select_dtypes(["string"])
let num_cols = df_drop.select_dtypes(["int32", "float32"])
str_cols.print()
num_cols.print()
//add new column to Dataframe
let new_vals = df['Fare'].round().values
df_drop.addColumn({ column: "fare_round", value: new_vals})
df_drop.print()
df_drop['fare_round'].print(5)
//prints the number of occurence each value in the column
df_drop['Survived'].value_counts().print()
//print the last ten elementa of a DataFrame
df_drop.tail(10).print()
//prints the number of missing values in a DataFrame
df_drop.isna().sum().print()
}).catch(err => {
console.log(err);
})
To use danfo.js via script tags, copy and paste the CDN below to your HTML file
<script src="https://cdn.jsdelivr.net/npm/danfojs@0.0.13/dist/index.min.js"></script>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.jsdelivr.net/npm/danfojs@0.0.13/dist/index.min.js"></script>
<title>Document</title>
</head>
<body>
<div id="some_div"></div>
<div id="alldiv"></div>
<script>
dfd.read_csv("https://raw.githubusercontent.com/risenW/medium_tutorial_notebooks/master/train.csv")
.then(df => {
df.describe().print()
//prints in console
// Shape: (5,5)
// ββββββββββ€ββββββββββββββββββββ€ββββββββββββββββββββ€ββββββββββββββββββββ€ββββββββββββββββββββ€ββββββββββββββββββββ
// β β Product_Weight β Product_Shelf... β Product_Price β Product_Super... β Supermarket_O... β
// ββββββββββΌββββββββββββββββββββΌββββββββββββββββββββΌββββββββββββββββββββΌββββββββββββββββββββΌββββββββββββββββββββ’
// β count β 4188 β 4990 β 4990 β 4990 β 4990 β
// ββββββββββΌββββββββββββββββββββΌββββββββββββββββββββΌββββββββββββββββββββΌββββββββββββββββββββΌββββββββββββββββββββ’
// β mean β 12.908838 β 0.066916 β 391.803772 β 6103.52002 β 2004.783447 β
// ββββββββββΌββββββββββββββββββββΌββββββββββββββββββββΌββββββββββββββββββββΌββββββββββββββββββββΌββββββββββββββββββββ’
// β std β NaN β 0.053058 β 119.378259 β 4447.333835 β 8.283151 β
// ββββββββββΌββββββββββββββββββββΌββββββββββββββββββββΌββββββββββββββββββββΌββββββββββββββββββββΌββββββββββββββββββββ’
// β min β 4.555 β 0 β 78.730003 β 83.230003 β 1992 β
// ββββββββββΌββββββββββββββββββββΌββββββββββββββββββββΌββββββββββββββββββββΌββββββββββββββββββββΌββββββββββββββββββββ’
// β median β NaN β 0.053564 β 393.86 β 5374.675 β 2006 β
// ββββββββββ§ββββββββββββββββββββ§ββββββββββββββββββββ§ββββββββββββββββββββ§ββββββββββββββββββββ§ββββββββββββββββββββ
var layout = {
title: 'A sample plot',
xaxis: {
title: 'X',
},
yaxis: {
title: 'Y',
}
};
//Displays plot in the specified div
df['Product_Weight'].plot("some_div", { kind: "histogram" })
df.plot("alldiv", { x: "Product_Price", y: "Product_Shelf_Visibility", kind: "scatter", mode: 'markers' })
}).catch(err => {
console.log(err);
})
</script>
</body>
</html>
To install danfo in [development mode], clone the repo:
git clone https://github.com/opensource9ja/danfojs
cd into danfojs folder and run:
npm install
The official documentation can be found here
Most development discussions take place on github in this repo. Feel free to use the issues tab.
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. As contributors and maintainers to this project, you are expected to abide by danfo' code of conduct. More information can be found at: Contributor Code of Conduct Javascript version of Pandas
FAQs
JavaScript library providing high performance, intuitive, and easy to use data structures for manipulating and processing structured data.
The npm package danfojs-node receives a total of 2,783 weekly downloads. As such, danfojs-node popularity was classified as popular.
We found that danfojs-node demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Β It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socketβs new workflow scanning support.
Product
Add real-time Socket webhook events to your workflows to automatically receive pull request scan results and security alerts in real time.
Research
The Socket Threat Research Team uncovered malicious NuGet packages typosquatting the popular Nethereum project to steal wallet keys.