Skip to content

Commit

Permalink
docs: Fix Sum(), closes #28
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Oct 3, 2023
1 parent dffb01b commit db82ec6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
12 changes: 6 additions & 6 deletions docs/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ The emissions dataset includes data for several states. We'll look at the states
days = emissions.group_by('day', key_type=agate.Number())
day_totals = days.aggregate([
('so2', agate.Sum(), 'so2'),
('co2', agate.Sum(), 'co2'),
('nox', agate.Sum(), 'nox')
('so2', agate.Sum('so2')),
('co2', agate.Sum('co2')),
('nox', agate.Sum('nox'))
])
The :code:`day_totals` table now contains total counts of each type of emission. Note that we don't know if this data is comprehensive so we shouldn't assume these are national totals. (In fact, I know that they aren't for reasons that will become obvious shortly.)
Expand Down Expand Up @@ -120,9 +120,9 @@ You may also want to render charts that compare to series of data. For instance,
states = emissions.group_by('State')
state_totals = states.aggregate([
('so2', agate.Sum(), 'so2'),
('co2', agate.Sum(), 'co2'),
('noX', agate.Sum(), 'noX')
('so2', agate.Sum('so2')),
('co2', agate.Sum('co2')),
('noX', agate.Sum('noX'))
])
state_totals.bar_chart('State', ['so2', 'noX'])
Expand Down
18 changes: 9 additions & 9 deletions example.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,26 @@

states = emissions.group_by('State')
state_totals = states.aggregate([
('so2', agate.Sum(), 'so2'),
('co2', agate.Sum(), 'co2'),
('noX', agate.Sum(), 'noX')
('so2', agate.Sum('so2')),
('co2', agate.Sum('co2')),
('noX', agate.Sum('noX'))
])

new_york = states['NY']

# NB: key_type shouldn't be necessary--agate bug #234
days = emissions.group_by('day', key_type=agate.Number())
day_totals = days.aggregate([
('so2', agate.Sum(), 'so2'),
('co2', agate.Sum(), 'co2'),
('noX', agate.Sum(), 'noX')
('so2', agate.Sum('so2')),
('co2', agate.Sum('co2')),
('noX', agate.Sum('noX'))
])

dates = emissions.group_by(' Date', key_type=agate.Date('%Y-%m-%d'))
date_totals = dates.aggregate([
('so2', agate.Sum(), 'so2'),
('co2', agate.Sum(), 'co2'),
('noX', agate.Sum(), 'noX')
('so2', agate.Sum('so2')),
('co2', agate.Sum('co2')),
('noX', agate.Sum('noX'))
])

print('Simple charts')
Expand Down

0 comments on commit db82ec6

Please sign in to comment.