npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

spm-dataframe

v1.0.21

Published

data frame for statistics

Downloads

6

Readme

dataframe spm version


Install

$ spm install dataframe --save

Usage

var Frame = require('dataframe');

var data = [ 
  {"name":"Mazda","mpg":"RX4","cyl":21,"disp":6,"hp":160,"drat":110,"wt":3.9,"qsec":2.62,"vs":16.46,"am":0,"gear":1,"carb":4},
  {"name":"Mazda","mpg":"RX4","cyl":"Wag","disp":21,"hp":6,"drat":160,"wt":110,"qsec":3.9,"vs":2.875,"am":17.02,"gear":0,"carb":1}
];
// 创建 frame
var f = new Frame(data);

// use dataframe

API

属性

isFrame Boolean

  • 是否是数据集合

arr Array

  • 数据集合的列数组,每列是一个子数组

names Array

  • 列名称

方法

colNames() Array

  • 返回 names

colCount() Number

  • 数据集合列的个数

colIndex(name) Number

  • 根据列名称获取对应的索引

colArray(name) Array

  • 根据列名称、索引获取列对应的数组

colReplace(name,arr) chainable

  • 替换数据集合中的列数组
  • name 可以是列名称也可以是索引
  • 返回数据集合本身,数据集合发生改变

rowCount() Number

  • 数据集合行的个数

rowObject(index) Object

  • 根据索引获取行对象

cell(rowIndex,colName) *

  • 返回指定行索引和列名称(列索引)的数值

toArray() Array

  • 将数据集合生成列数组

toJSON() Array

  • 将数据集合生成JSON 数组

s() String

  • 将整个数据集合生成字符串,一般用于调试输出现有集合

下列方法生成新的数据集合

col(name) Frame

  • 根据列名称或者索引生成新的数据集合

cols(names) Frame

  • 根据多个列名称或者索引生成新的数据集合

row(rowInde) Frame

  • 根据行索引生成新的数据集合

rows(rowIndexs) Frame

  • 根据多个行索引生成新的数据集合

sub(startCol,endCol,startRow,endRow) Frame

  • 根据行和列获取一个子集合

静态方法

mean(frame,x) Number

  • 计算列x的平局值

geometric_mean(frame,x) Number

  • 计算列x的列的几何均值

sum(frame,x) Number

  • 计算列x的和

max(frame,x) Number

  • 计算列x的最大值

min(frame,x) Number

  • 计算列x的最小值

range(frame,x) Array

  • 计算列x的最小值和最大值

model(frame,x) Number

  • 计算列x的众数,最多的数

median(frame,x) Number

  • 计算列x的中位数

variance(frame,x) Number

  • 计算列x的方差

standard_deviation(frame,x) Number

  • 计算列x的标准方差

sort(frame,x) Frame

  • 返回按照列排序后的数据集合

group(frame,condition) Array

  • 按照条件进行分组,返回 [frame1,frame2...framen]
  • condition条件可以是列名的数组也可以是一个函数返回一个唯一的键值

groupToMap(frame,condition) Array

  • 按照条件进行分组,形成map,键值对,返回 {key1: frame1,key2: frame2,key3: frame3....keyn:framen}
  • condition条件可以是列名的数组也可以是一个函数返回一个唯一的键值

complement(frame,cols) Frame

  • 取指定列的补集组成的数据集合,例如 names: ['a','b','c','d'], Frame.complement(frame,['a','c']),生成的names : ['b','d']的数据集合

merge(frame1,frame2...framen) Frame

  • 合并传入的集合成为一个集合,列不发生变化,假设传入的集合的列一致,仅是增加行

combin(frame1,frame2...framen) Frame

  • 合并传入的集合成为一个集合,列进行组合,行的数目不变,仅仅是列变化