Closed shankari closed 3 years ago
@start0318 can you test with an actual missing value to ensure that it works? You can do this by removing some of the values from the existing purpose dict.
This also happens with the current generic_metrics_ebike_project
notebook. I suspect we weren't running into this earlier because we were only plotting the top 10 purposes. Now that we dynamically merge the small entries, we are running into this.
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-18-44b09bc13a9a> in <module>
3 plot_title="Number of trips for each purposes (selected by users)\n%s" % quality_text
4 file_name= 'ntrips_purpose%s.png' % file_suffix
----> 5 pie_chart_purpose(plot_title,labels_tp,values_tp,file_name)
6 print(expanded_ct['Trip_purpose'].value_counts(dropna=True))
/usr/src/app/saved-notebooks/plots.py in pie_chart_purpose(plot_title, labels, values, file_name)
120 wedges, texts, autotexts = ax.pie(m_values,
121 labels = m_labels,
--> 122 colors=[colours[key] for key in labels],
123 pctdistance=0.85,
124 autopct=lambda pct: func(pct, values),
/usr/src/app/saved-notebooks/plots.py in <listcomp>(.0)
120 wedges, texts, autotexts = ax.pie(m_values,
121 labels = m_labels,
--> 122 colors=[colours[key] for key in labels],
123 pctdistance=0.85,
124 autopct=lambda pct: func(pct, values),
KeyError: 'gas'
Fixed this with these two lines in notebooks
dic_pur = defaultdict(lambda: 'Other',dic_pur) dic_re = defaultdict(lambda: 'Other',dic_re)
closed by #22
Got the following error while trying to generate entries for February. Clearly we don't have a mapping for
gasolinera
, but I thought that should be handled by the missing_dict code, at least for now.