Skip to content

Commit

Permalink
Add rank cookbook recipes. Closes #110. Closes #160.
Browse files Browse the repository at this point in the history
  • Loading branch information
onyxfish committed Sep 7, 2015
1 parent 46a870d commit 8b6dcfe
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions docs/cookbook/ranking.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,34 @@
Ranking
=======

Ranking is a complicated science. agate strives to find a balance between simple, intuitive ranking and flexibility when you need it.
There are many ways to rank a sequence of values. agate strives to find a balance between simple, intuitive ranking and flexibility when you need it.

Competition rank
================

The basic rank supported by agate is standard "competition ranking". In this model the values :code:`[3, 4, 4, 5]` would be ranked :code:`[1, 2, 2, 4]`. You can apply competition ranking using the :class:`.Rank` computation:

.. code-block:: python
new_table = table.compute([
('rank', agate.Rank('value')
])
Rank change
===========
You can compute the change from one rank to another by combining the :class:`.Rank` and class:`.Change` computations:
.. code-block:: python
new_table = table.compute([
('rank2014', agate.Rank('value2014'),
('rank2015', agate.Rank('value2015')
])
new_table2 = table.compute([
('rank_change', agate.Change('rank2014', 'rank2015')
])
Percentile rank
===============
Expand All @@ -11,10 +38,8 @@ Percentile rank
.. code-block:: Python
from agate import PercentileRank
new_table = table.compute([
('percentile_rank', PercentileRank('value')
('percentile_rank', agate.PercentileRank('value')
])
Note that there is no entirely standard method for computing percentiles. The percentiles computed in this manner may not agree with those generated by other programes. See the :class:`.Percentiles` class documentation for implementation details.

0 comments on commit 8b6dcfe

Please sign in to comment.