import agate
# Group by county
counties = leso.group_by('county')
# Filter to counties with more than $200,000 in equipment
top_counties = counties.having([
('total_cost_sum', agate.Sum('total_cost'))
], lambda t: t['total_cost_sum'] > 200000)
# Group a second time—see the section on "Multidimensional aggregation"
counties_and_items = top_counties.group_by('federal_supply_category_name')
# Aggregate sums by county and item
counts = counties_and_items.aggregate([
('quantity_sum', agate.Sum('quantity'))
])
# Sort by item, regroup by county, and then plot a line chart for each county
counts.order_by('quantity_sum', reverse=True).group_by('federal_supply_category_name').bar_chart(label='federal_supply_category_name', value='quantity_sum')
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-105-ed28ead4c510> in <module>()
18
19 # Sort by item, regroup by county, and then plot a line chart for each county
---> 20 counts.order_by('quantity_sum', reverse=True).group_by('federal_supply_category_name').bar_chart(label='federal_supply_category_name', value='quantity_sum')
/Users/cgroskopf/src/agate/agate/tableset/bar_chart.py in bar_chart(self, label, value, path, width, height)
31 label_name = label
32
---> 33 if type(value) is int:
34 value_name = self.column_names[value]
35 else:
/Users/cgroskopf/.virtualenvs/agate/lib/python3.5/site-packages/leather/lattice.py in to_svg(self, path, width, height)
150
151 if not self._scales[Y]:
--> 152 self._scales[Y]= Scale.infer(layers, Y, self._types[Y])
153
154 if not self._axes[X]:
/Users/cgroskopf/.virtualenvs/agate/lib/python3.5/site-packages/leather/scales/base.py in infer(cls, layers, dimension, data_type)
87
88 if series.values(dimension) != scale_values:
---> 89 raise ValueError('All series must have the same values for scale display.')
90
91 scale = Ordinal(scale_values)
ValueError: All series must have the same values for scale display.
From wireservice/agate#643