Pivot table not working - unhashable type: 'dict'
See original GitHub issueSuperset version
Superset 0.23.0dev
Expected results
Pivot table should display the table with results.
Actual results
unhashable type: ‘dict’
Steps to reproduce
- Install superset, load sample data as given in the installation guide
- Create pivot table with any table and choose any metric except
Count(*)
. Because its working only for Count(*) metric. - Run Query
PS: The same query working for other chart types with same parameters.
Stacktrace:
2018-05-11 17:17:36,253:DEBUG:root:[stats_logger] (incr) explore_json
2018-05-11 17:17:36,375:DEBUG:parsedatetime:eval now with context - False, False
2018-05-11 17:17:36,376:INFO:root:Cache key: 0ee55f4b95926a7373cfbf36300e1d71
2018-05-11 17:17:36,380:INFO:root:Database.get_sqla_engine(). Masked URL: sqlite:////home/gancha/.superset/superset.db
2018-05-11 17:17:36,388:INFO:root:SELECT gender AS gender, SUM(num) AS "SUM(num)"
FROM birth_names
WHERE ds >= '1918-05-11 00:00:00.000000' AND ds <= '2018-05-11 17:17:36.000000' GROUP BY gender ORDER BY "SUM(num)" DESC
LIMIT 10000 OFFSET 0
2018-05-11 17:17:36,405:INFO:root:Database.get_sqla_engine(). Masked URL: sqlite:////home/gancha/.superset/superset.db
2018-05-11 17:17:36,464:DEBUG:root:[stats_logger] (incr) loaded_from_source
2018-05-11 17:17:40,465:ERROR:root:unhashable type: 'dict'
Traceback (most recent call last):
File "/home/gancha/superset/superset/views/core.py", line 1107, in generate_json
payload = viz_obj.get_payload()
File "/home/gancha/superset/superset/viz.py", line 371, in get_payload
payload['data'] = self.get_data(df)
File "/home/gancha/superset/superset/viz.py", line 670, in get_data
margins=self.form_data.get('pivot_margins'),
File "/home/gancha/superset/venv/lib/python2.7/site-packages/pandas/core/frame.py", line 4468, in pivot_table
margins_name=margins_name)
File "/home/gancha/superset/venv/lib/python2.7/site-packages/pandas/core/reshape/pivot.py", line 57, in pivot_table
if i not in data:
File "/home/gancha/superset/venv/lib/python2.7/site-packages/pandas/core/generic.py", line 1075, in __contains__
return key in self._info_axis
File "/home/gancha/superset/venv/lib/python2.7/site-packages/pandas/core/indexes/base.py", line 1694, in __contains__
hash(key)
TypeError: unhashable type: 'dict'
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Pivot table not working - unhashable type: 'dict' #4984 - GitHub
Create pivot table with any table and choose any metric except Count(*) . Because its working only for Count(*) metric. Run Query. PS:...
Read more >TypeError: Unhashable type numpy.ndarray on pivot_table
Any ideas how to resolve this? Do I need to change anything in my columns? python-3.x · pandas · pivot-table.
Read more >How to Handle Unhashable Type List Exceptions in Python
The standard way to solve this issue is to cast a list to a tuple, which is a hashable data type.
Read more >Python: TypeError: unhashable type: 'list' - Net-Informations.Com
This error shows that the my_dict key [1,2,3] is List and List is not a hashable type in Python . Dictionary keys must...
Read more >Dictionaries In Python - Nbshare Notebooks
Dictionaries in Python. You can define a dictionary by enclosing a comma-separated list of key-value pairs in curly braces ({}).
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Did your original query work when doing heatmaps? I have a table which has row and column and a value at that row and column (all ints) and when I do X=row, Y=col, metric=value, I get unhashable dict error just as above. If this is unrelated, I can open another issue but it is basically the exact same but for histogram charts.
I read souce code, find the reason.
The reason is superset change the data struct of
metric
. So in some situation it is work, but some not.Before change, the type of
metric
isstr
, but after change the type ofmetric
isdict
.For example. Before
After
Solution
Change the file
viz.py
get metric code of perget_data
function. We should makemetric
is astr
.Like this.
Then
CountryMapViz
is OK.