graceful handling of the "no numeric data to plot" error
andrewsu opened this issue · comments
Andrew Su commented
Right now, the script produces many errors like this:
Q64:Please reflect on your mentoring experience. How can the mentorship climate at Scripps Research be improved for mentors?
Traceback (most recent call last):
File "/home/asu/Science/mentorship-survey-analysis/main.py", line 156, in plot_bar_charts
plottable_df.plot.barh(stacked=True, ax=axes[i])
File "/home/asu/env/mentorship-survey-analysis/lib/python3.10/site-packages/pandas/plotting/_core.py", line 1222, in barh
return self(kind="barh", x=x, y=y, **kwargs)
File "/home/asu/env/mentorship-survey-analysis/lib/python3.10/site-packages/pandas/plotting/_core.py", line 975, in __call__
return plot_backend.plot(data, kind=kind, **kwargs)
File "/home/asu/env/mentorship-survey-analysis/lib/python3.10/site-packages/pandas/plotting/_matplotlib/__init__.py", line 71, in plot
plot_obj.generate()
File "/home/asu/env/mentorship-survey-analysis/lib/python3.10/site-packages/pandas/plotting/_matplotlib/core.py", line 446, in generate
self._compute_plot_data()
File "/home/asu/env/mentorship-survey-analysis/lib/python3.10/site-packages/pandas/plotting/_matplotlib/core.py", line 632, in _compute_plot_data
raise TypeError("no numeric data to plot")
TypeError: no numeric data to plot
no numeric data to plot
These are expected errors given the sample data file and they do not indicate anything is actually going wrong, but their appearance in the console output may confuse users who are not familiar with the reason. It would be nice to catch these errors more gracefully.
Rohan Juneja commented
These errors are already caught -- I just have it printed to the console for debugging purposes on
mentorship-survey-analysis/main.py
Line 190 in 65c39ac