Skip to content

Commit

Permalink
Merge pull request #201 from nsonnad/tutorial-syntax-fixes
Browse files Browse the repository at this point in the history
Fix some syntax errors in the tutorial
  • Loading branch information
onyxfish committed Sep 1, 2015
2 parents d0c9ee1 + b0de909 commit ec25f4b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions docs/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -252,16 +252,16 @@ For instance, this example will create a ``full_name`` column from the ``first_n
.. code-block:: python
full_names = exonerations.compute([
('full_name', agate.Formula(text_type, lambda row: '%(first_name)s %(last_name)s' % row)
('full_name', agate.Formula(text_type, lambda row: '%(first_name)s %(last_name)s' % row))
])
For efficiencies sake, agate allows you to perform several computations at once.

.. code-block:: python
with_computations = exonerations.compute([
('years_in_prison', agate.Change('convicted', 'exonerated')),
('full_name', agate.Formula(text_type, lambda row: '%(first_name)s %(last_name)s' % row)
('full_name', agate.Formula(text_type, lambda row: '%(first_name)s %(last_name)s' % row)),
('years_in_prison', agate.Change('convicted', 'exonerated'))
])
If :class:`.Formula` still is not flexible enough (for instance, if you need to compute a new row based on the distribution of data in a column) you can always implement your own subclass of :class:`.Computation`. See the API documentation for :mod:`.computations` to see all of the supported ways to compute new data.
Expand Down Expand Up @@ -331,7 +331,7 @@ This takes our original :class:`.Table` and groups it into a :class:`.TableSet`,
state_totals = by_state.aggregate()
sorted_totals = totals.order_by('count', reverse=True)
sorted_totals = state_totals.order_by('count', reverse=True)
print(sorted_totals.format(max_rows=5))
Expand Down Expand Up @@ -364,8 +364,8 @@ This is a much more complicated question that's going to pull together a lot of
state_totals = with_years_in_prison.group_by('state')
medians = totals.aggregate([
('years_in_prison', Median(), 'median_years_in_prison')
medians = state_totals.aggregate([
('years_in_prison', agate.Median(), 'median_years_in_prison')
])
sorted_medians = medians.order_by('median_years_in_prison', reverse=True)
Expand Down

0 comments on commit ec25f4b

Please sign in to comment.