# pandas-js

> Pandas for JavaScript

Latest version **0.2.4** (published 2017-09-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install pandas-js
pnpm add pandas-js
yarn add pandas-js
bun add pandas-js
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.4 |
| Published | 2017-09-04 |
| First published | 2016-12-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 464 |
| Author | StratoDem Analytics tech@stratodem.com |
| Maintainers | stratodem |
| Keywords | pandas, data-analysis, analytics |

## Links

- npm: https://www.npmjs.com/package/pandas-js
- Repository: https://github.com/StratoDem/pandas-js
- Issues: https://github.com/StratoDem/pandas-js/issues
- npm.io page: https://npm.io/package/pandas-js

## Dependencies (1)

- [immutable](https://npm.io/package/immutable.md) ^3.8.1

## Recent versions

- 0.2.4 (latest) — 2017-09-04
- 0.2.3 — 2017-09-04
- 0.2.1 — 2017-08-20
- 0.2.0 — 2017-08-11
- 0.1.28 — 2017-05-17
- 0.1.27 — 2017-03-08
- 0.1.26 — 2017-02-16
- 0.1.25 — 2017-02-12
- 0.1.24 — 2017-02-12
- 0.1.23 — 2017-02-09
- 0.1.22 — 2017-02-09
- 0.1.21 — 2017-02-09
- 0.1.20 — 2017-02-05
- 0.1.19 — 2017-02-03
- 0.1.18 — 2017-02-01
- … 18 more at https://npm.io/package/pandas-js/versions

## README

# pandas-js
Pandas for JavaScript

pandas.js is an open source (experimental) library mimicking the
Python [pandas](http://pandas.pydata.org/) library. It relies on
[Immutable.js](https://facebook.github.io/immutable-js/) as the
[NumPy](http://www.numpy.org/) base. The main data
objects in pandas.js are the [`Series`](#series) and the
[`DataFrame`](#dataframe)

## Documentation

See [the docs](https://stratodem.github.io/pandas.js-docs/)  
See also [this post](https://insights.stratodem.com/pandas-immutable-js-2d9bf010639b) on use for optimizing React logic.

## Installation and use
```
$ npm install pandas-js
```

Importing
[`Series`](https://stratodem.github.io/pandas.js-docs/#series)
and
[`DataFrame`](https://stratodem.github.io/pandas.js-docs/#dataframe)
```js
import { Series, DataFrame } from 'pandas-js';
```

Create a new `Series`
```js
const ds = new Series([1, 2, 3, 4], {name: 'My test name', index: [2, 3, 4, 5]})
ds.toString()
// Returns:
// 2  1
// 3  2
// 4  3
// 5  4
// Name: My test name, dtype: dtype(int)
```

Filter a `Series`
```js
const ds = new Series([1, 2, 3]);

// Returns Series([2, 3]);
ds.filter(ds.gte(2));
```

Filtering can be done with generic methods
- [`eq`](https://stratodem.github.io/pandas.js-docs/#series-eq)
- [`lt`](https://stratodem.github.io/pandas.js-docs/#series-lt)
- [`gt`](https://stratodem.github.io/pandas.js-docs/#series-gt)
- [`lte`](https://stratodem.github.io/pandas.js-docs/#series-lte)
- [`gte`](https://stratodem.github.io/pandas.js-docs/#series-gte)

```js
const ds = new Series([1, 2, 3], {name: 'Test name'})

// Returns Series([true, false, false])
ds.eq(1);

// Returns Series([false, true, true])
ds.eq(new Series([0, 2, 3]));

// Returns Series([false, true, true])
ds.eq(Immutable.List([0, 2, 3]));

// Returns Series([false, true, true])
ds.eq([0, 2, 3]);

// Returns Series([2, 3])
ds.filter(ds.eq([0, 2, 3]));
```

Create a new `DataFrame`
```js
const df = new DataFrame([{x: 1, y: 2}, {x: 2, y: 3}, {x: 3, y: 4}])

// Returns:
//    x  |  y
// 0  1  |  2
// 1  2  |  3
// 2  3  |  4
df.toString();
```

Filtering a `DataFrame`

```js
const df = new DataFrame(Immutable.Map({x: new Series([1, 2]), y: new Series([2, 3])}));

// Returns DataFrame(Immutable.Map({x: Series([2]), y: Series([3]));
df.filter(df.get('x').gt(1));

// Returns DataFrame(Immutable.Map({x: Series([2]), y: Series([3]));
df.filter([false, true]);

// Returns DataFrame(Immutable.Map({x: Series([2]), y: Series([3]));
df.filter(Immutable.Map([false, true]));
```

## Development

### Testing and build
```
$ npm run test
$ npm run build
```
Testing uses [Jest](https://facebook.github.io/jest/). Building requires the babel compiler.

---
_Source: https://npm.io/package/pandas-js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
