<commit_before>[![npm](http://nicolas.kruchten.com/pivottable/images/npm.svg)](https://www.npmjs.com/package/pivottable) [![cdnjs](http://nicolas.kruchten.com/pivottable/images/cdnjs.svg)](https://cdnjs.com/libraries/pivottable) [![tests](http://nicolas.kruchten.com/pivottable/images/tests.svg)](http://nicolas.kruchten.com/pivottable/tests/) [![license](http://nicolas.kruchten.com/pivottable/images/license.svg)](https://github.com/nicolaskruchten/pivottable/blob/master/LICENSE.md)


# PivotTable.js

PivotTable.js is a Javascript Pivot Table library with drag'n'drop functionality built on top of jQuery/jQueryUI and originally written in CoffeeScript by [<NAME>](http://nicolas.kruchten.com) at [Datacratic](http://datacratic.com).

It is available under an MIT license from [CDNJS](https://cdnjs.com/libraries/pivottable) and [NPM](https://www.npmjs.com/package/pivottable) and [Bower](http://bower.io/) under the name `pivottable`.

PivotTable.js can be used with [Python/Jupyter](https://pypi.python.org/pypi/pivottablejs) and [R/RStudio](https://github.com/smartinsightsfromdata/rpivotTable) and you can [try it right now](http://nicolas.kruchten.com/pivottable/examples/local.html) in your browser on a CSV file.

## What does it do?

PivotTable.js' basic function is to enable data exploration and analysis by turning a data set into a summary table and then optionally adding a true 2-d drag'n'drop UI to allow a user to manipulate this summary table, turning it into a pivot table, very similar to the one found in older versions of Microsoft Excel with a bunch of extra developer-oriented features and some visualization effects. With [optional add-ons](https://github.com/nicolaskruchten/pivottable/wiki/Optional-Extra-Renderers), the summary table can be rendered as various kinds of charts, turning the pivot table into a pivot chart.

![image](http://nicolas.kruchten.com/pivottable/images/animation.gif)

The animation above is based on the [Canadian Parliament 2012 dataset example](http://nicolas.kruchten.com/pivottable/examples/fully_loaded.html).

## Where are the demos/examples?

There are lots on the [examples page](http://nicolas.kruchten.com/pivottable/examples/index.html) but here are some good entry points:

* [a JSFiddle where you can play with the code](https://jsfiddle.net/nicolaskruchten/kn381h7s/)
* [a simple demo running on the "Canadian Parliament 2012" dataset](http://nicolaskruchten.github.io/pivottable/examples/mps_prepop.html)
* [fully-loaded demo running on the 700+ datasets that ship with R](http://nicolas.kruchten.com/pivottable/examples/rcsvs.html)
* [fully-loaded demo where you provide your own CSV file for input](http://nicolas.kruchten.com/pivottable/examples/local.html)

## Why is it good?

* it's lightweight: the core (without chart support) is a single file with less than 1000 LOC of CoffeeScript, compiles down to 6.3kb of Javascript minified and gzipped, and depends only on jQuery and jQueryUI's 'sortable'
* it works wherever jQuery and jQueryUI work (tested with jQuery 1.8.3 and jQueryUI 1.9.2)
* it works acceptably fast in Chrome on commodity hardware up to around a hundred thousand records, depending on the cardinality of the attributes.
* its UI is [localizable](https://github.com/nicolaskruchten/pivottable/wiki/Localization)
* its layered architecture allows for summary table generation with or without the pivot table UI around it (if you don't use the UI, then there is no dependency on jQueryUI)
* it works with common [input formats](https://github.com/nicolaskruchten/pivottable/wiki/Input-Formats)
* its [derived attributes](https://github.com/nicolaskruchten/pivottable/wiki/Derived-Attributes) can be created on the fly based on the whole input record by passing in a function
* its complex [aggregation functions](https://github.com/nicolaskruchten/pivottable/wiki/Aggregators) can compute values based on the whole input record (e.g. weighted averages)<commit_msg>PivotTable.js is now available on Packagist.org (The PHP Package Repository) (#609)<commit_after>[![npm](http://nicolas.kruchten.com/pivottable/images/npm.svg)](https://www.npmjs.com/package/pivottable) [![cdnjs](http://nicolas.kruchten.com/pivottable/images/cdnjs.svg)](https://cdnjs.com/libraries/pivottable) [![tests](http://nicolas.kruchten.com/pivottable/images/tests.svg)](http://nicolas.kruchten.com/pivottable/tests/) [![license](http://nicolas.kruchten.com/pivottable/images/license.svg)](https://github.com/nicolaskruchten/pivottable/blob/master/LICENSE.md)


# PivotTable.js

PivotTable.js is a Javascript Pivot Table library with drag'n'drop functionality built on top of jQuery/jQueryUI and originally written in CoffeeScript by [<NAME>](http://nicolas.kruchten.com) at [Datacratic](http://datacratic.com).

It is available under an MIT license from [CDNJS](https://cdnjs.com/libraries/pivottable) and [NPM](https://www.npmjs.com/package/pivottable) and [Bower](http://bower.io/) under the name `pivottable`. And on [Packagist.org](https://github.com/nicolaskruchten/pivottable), it is `nicolaskruchten/pivottable`. 

PivotTable.js can be used with [Python/Jupyter](https://pypi.python.org/pypi/pivottablejs) and [R/RStudio](https://github.com/smartinsightsfromdata/rpivotTable) and you can [try it right now](http://nicolas.kruchten.com/pivottable/examples/local.html) in your browser on a CSV file.

## What does it do?

PivotTable.js' basic function is to enable data exploration and analysis by turning a data set into a summary table and then optionally adding a true 2-d drag'n'drop UI to allow a user to manipulate this summary table, turning it into a pivot table, very similar to the one found in older versions of Microsoft Excel with a bunch of extra developer-oriented features and some visualization effects. With [optional add-ons](https://github.com/nicolaskruchten/pivottable/wiki/Optional-Extra-Renderers), the summary table can be rendered as various kinds of charts, turning the pivot table into a pivot chart.

![image](http://nicolas.kruchten.com/pivottable/images/animation.gif)

The animation above is based on the [Canadian Parliament 2012 dataset example](http://nicolas.kruchten.com/pivottable/examples/fully_loaded.html).

## Where are the demos/examples?

There are lots on the [examples page](http://nicolas.kruchten.com/pivottable/examples/index.html) but here are some good entry points:

* [a JSFiddle where you can play with the code](https://jsfiddle.net/nicolaskruchten/kn381h7s/)
* [a simple demo running on the "Canadian Parliament 2012" dataset](http://nicolaskruchten.github.io/pivottable/examples/mps_prepop.html)
* [fully-loaded demo running on the 700+ datasets that ship with R](http://nicolas.kruchten.com/pivottable/examples/rcsvs.html)
* [fully-loaded demo where you provide your own CSV file for input](http://nicolas.kruchten.com/pivottable/examples/local.html)

## Why is it good?

* it's lightweight: the core (without chart support) is a single file with less than 1000 LOC of CoffeeScript, compiles down to 6.3kb of Javascript minified and gzipped, and depends only on jQuery and jQueryUI's 'sortable'
* it works wherever jQuery and jQueryUI work (tested with jQuery 1.8.3 and jQueryUI 1.9.2)
* it works acceptably fast in Chrome on commodity hardware up to around a hundred thousand records, depending on the cardinality of the attributes.
* its UI is [localizable](https://github.com/nicolaskruchten/pivottable/wiki/Localization)
* its layered architecture allows for summary table generation with or without the pivot table UI around it (if you don't use the UI, then there is no dependency on jQueryUI)
* it works with common [input formats](https://github.com/nicolaskruchten/pivottable/wiki/Input-Formats)
* its [derived attributes](https://github.com/nicolaskruchten/pivottable/wiki/Derived-Attributes) can be created on the fly based on the whole input record by passing in a function
* its complex [aggregation functions](https://github.com/nicolaskruchten/pivottable/wiki/Aggregators) can compute values based on the whole input record (e.g. weighted averages)
{'fraction_non_alphanumeric': 0.1078843302026693, 'fraction_numerical': 0.007291151754819575, 'mean_word_length': 5.2542503863987635, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 27, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2512422', 'n_tokens_mistral': 2580, 'n_tokens_neox': 2409, 'n_words': 783}