Skip to content

Commit

Permalink
docs: Fix compute(), closes #27
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Oct 3, 2023
1 parent db82ec6 commit 2c15de4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions docs/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ Now let's compute a few derived columns in order to make our charting easier. Th
.. code-block:: python
emissions = emissions.compute([
(agate.Formula(agate.Number(), lambda r: r[' Date'].day), 'day'),
(agate.Formula(agate.Number(), lambda r: r[' SO2 (tons)'] or 0), 'so2'),
(agate.Formula(agate.Number(), lambda r: r[' NOx (tons)'] or 0), 'nox'),
(agate.Formula(agate.Number(), lambda r: r[' CO2 (short tons)'] or 0), 'co2')
('day', agate.Formula(agate.Number(), lambda r: r[' Date'].day)),
('so2', agate.Formula(agate.Number(), lambda r: r[' SO2 (tons)'] or 0)),
('nox', agate.Formula(agate.Number(), lambda r: r[' NOx (tons)'] or 0)),
('co2', agate.Formula(agate.Number(), lambda r: r[' CO2 (short tons)'] or 0))
])
Of course, for analysis purposes you should always be extremely cautious in assuming that blank fields are equivalent to zero. For the purposes of this tutorial, we will assume this is a valid transformation.
Expand Down
8 changes: 4 additions & 4 deletions example.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
emissions = agate.Table.from_csv('examples/epa-emissions-20150910.csv', tester)

emissions = emissions.compute([
(agate.Formula(agate.Number(), lambda r: r[' Date'].day), 'day'),
(agate.Formula(agate.Number(), lambda r: r[' SO2 (tons)'] or 0), 'so2'),
(agate.Formula(agate.Number(), lambda r: r[' NOx (tons)'] or 0), 'noX'),
(agate.Formula(agate.Number(), lambda r: r[' CO2 (short tons)'] or 0), 'co2')
('day', agate.Formula(agate.Number(), lambda r: r[' Date'].day)),
('so2', agate.Formula(agate.Number(), lambda r: r[' SO2 (tons)'] or 0)),
('noX', agate.Formula(agate.Number(), lambda r: r[' NOx (tons)'] or 0)),
('co2', agate.Formula(agate.Number(), lambda r: r[' CO2 (short tons)'] or 0))
])

states = emissions.group_by('State')
Expand Down

0 comments on commit 2c15de4

Please sign in to comment.