0
丹佛–它是Python熊猫的替代品吗?
数据科学是市场的新需求。 Python和R语言适用于分析和数据科学。如果你’是一个JS开发人员,想碰到这一行。然后,本教程适合您。
什么是DanfoJS?
一分钟,如果你’如果您具有Python熊猫知识,那么本文也将对您有所帮助。 DanfoJS是功能强大的javascript数据分析工具包。它是一个开放源代码的JavaScript库,可提供高性能,直观且易于使用的数据结构来处理和处理结构化数据。

另外,它是一个JavaScript包,可提供快速,灵活的功能。富有表现力的数据结构旨在与“relational” or “labeled”数据既简单又直观。它深受启发 大熊猫 library, 和 provides a similar API. This means that users familiar with 熊猫,可以轻松获取danfo.js。
DanfoJS可以做什么?
- 丹佛is fast. It is built on Tensorflow.js, 和 supports tensors out of the 框. This means you can 转换Danfo数据结构 to Tensors.
- 易于处理 missing-data (represented as
NaN
)以及非浮点数据 - 大小可变性:列可以 inserted/deleted from DataFrame
- 自动和明确 对齐:可以将对象显式对齐到一组标签,或者用户可以简单地忽略标签并让
Series
,DataFrame
等在计算中自动为您调整数据 - 强大,灵活 groupby functionality to perform split-apply-combine operations on 数据集, for both aggregating 和 transforming data
- Make it easy to convert Arrays, JSONs, List or Objects, Tensors 和 differently-indexed data structures into DataFrame objects
- 基于智能标签 slicing, fancy indexing, 和 querying of large 数据集
- 直觉的 merging and joining data sets
- 强大的IO工具可从中加载数据 flat-files (CSV 和 delimited).
- 强大,灵活 和 intutive API for plotting DataFrames 和 Series interactively.
- Timeseries-specific functionality: date range generation 和 date 和 time properties.
- 强大的数据预处理功能,例如 OneHotEncoders, LabelEncoders和缩放器,例如 StandardScaler and MinMaxScaler are supported on DataFrame 和 Series.
安装
There are two ways to get danfo.js. We built an optimized 和 fast version for 节点.js 和 its available under the 丹佛斯节点 命名空间。要通过npm安装它,可以执行以下操作:
1 |
npm 安装 丹佛斯-节点 |
You can also 安装 和 use it in the browsers by using the CDN below:
1 |
实作
DanfoJS可以与Node一起运行,也可以不与NodeJS一起运行。因此,首先来看一下基于HTML的代码。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
<!DOCTYPE html> <html 郎=“ en”> <head> <meta 字符集=“ UTF-8”> <meta 名称=“视口” 内容=“宽度=设备宽度,初始比例= 1.0”> <script src="//cdn.jsdelivr.net/npm/[电子邮件 protected]/dist/index.min.js“></script> <title>文件</title> </head> <body> <div ID="div1"></div> <div ID="div2"></div> <div ID="div3"></div> <script> dfd.read_csv("//raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv") .然后(df => { df['AAPL.Open'].情节("div1").框() //绘制箱形图 df.情节("div2").表() //将csv显示为表格 new_df = df.set_index({ 键: “日期” }) //将索引重置为“日期”列 new_df.情节("div3").线({ 列: [“ AAPL.Open”, “ AAPL.High”] }) //绘制时间序列图 }).抓住(呃 => { 安慰.日志(呃); }) </script> </body> </html> |
输出:
Node.js示例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
const dfd = 要求(“ 丹佛斯节点”) dfd.read_csv("//web.stanford.edu/class/archive/cs/cs109/cs109.1166/stuff/titanic.csv") .然后(df => { //打印前五列 df.头().打印() //计算所有数字列的描述统计 df.描述().打印() //打印数据的形状 安慰.日志(df.形状); //打印所有列名 安慰.日志(df.柱_names); //打印每列的推断dtype df.类型.打印() //通过子集选择列 df['名称'].打印() //按名称删除列 cols_2_remove = ['年龄', 'Pclass'] df_drop = df.下降({ 列: cols_2_remove, 轴: 1 }) df_drop.打印() //通过dtypes选择列 让 str_cols = df_drop.select_dtypes([“串”]) 让 num_cols = df_drop.select_dtypes([“ int32”, “ float32”]) str_cols.打印() num_cols.打印() //将新列添加到数据框 让 new_vals = df['票价'].回合().价值观 df_drop.addColumn({ 柱: “ fare_round”, 值: new_vals}) df_drop.打印() df_drop['fare_round'].打印(5) //打印列中每个值的出现次数 df_drop[幸存].值_counts().打印() //打印DataFrame的最后十个元素 df_drop.尾巴(10).打印() //在DataFrame中打印缺失值的数量 df_drop.伊斯纳().和().打印() }).抓住(呃 => { 安慰.日志(呃); }) |
语法类似于Python熊猫。您可以轻松完成熊猫所能完成的大部分工作。
请参阅有关的文档 更多.
0
概要
审稿人
达斯
审核日期
评论项目
丹佛- Is it alternative of Python 大熊猫
作者评分





软件名称
丹佛
软件名称
任何
软件类别
Java脚本,打字稿