Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lattice charts don't work if one group only contains nulls values #77

Open
onyxfish opened this issue Nov 15, 2016 · 0 comments
Open

Lattice charts don't work if one group only contains nulls values #77

onyxfish opened this issue Nov 15, 2016 · 0 comments
Labels

Comments

@onyxfish
Copy link
Collaborator

From wireservice/agate#644

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('item_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('item_name').bar_chart(label='item_name', value='quantity_sum')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-104-28220184eafb> 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('item_name').bar_chart(label='item_name', value='quantity_sum')

/Users/cgroskopf/src/agate/agate/tableset/bar_chart.py in bar_chart(self, label, value, path, width, height)
     29         label_name = self.column_names[label]
     30     else:
---> 31         label_name = label
     32 
     33     if type(value) is int:

/Users/cgroskopf/.virtualenvs/agate/lib/python3.5/site-packages/leather/lattice.py in add_many(self, data, x, y, titles)
    136             title = titles[i] if titles else None
    137 
--> 138             self.add_one(d, x=x, y=y, title=title)
    139 
    140     def to_svg(self, path=None, width=None, height=None):

/Users/cgroskopf/.virtualenvs/agate/lib/python3.5/site-packages/leather/lattice.py in add_one(self, data, x, y, title)
    111             A title to render above this chart.
    112         """
--> 113         series = Series(data, x=x, y=y, name=title)
    114 
    115         for dimension in [X, Y]:

/Users/cgroskopf/.virtualenvs/agate/lib/python3.5/site-packages/leather/series/base.py in __init__(self, data, x, y, name)
     55         self._types = [
     56             self._infer_type(self._keys[X]),
---> 57             self._infer_type(self._keys[Y])
     58         ]
     59 

/Users/cgroskopf/.virtualenvs/agate/lib/python3.5/site-packages/leather/series/base.py in _infer_type(self, key)
     78 
     79         if v is None:
---> 80             raise ValueError('All values in dimension was null.')
     81 
     82         return DataType.infer(v)

ValueError: All values in dimension was null.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants