-
Notifications
You must be signed in to change notification settings - Fork 1.1k
turicreate.show bad_get error #141
Comments
@radikal9 Can you upload the As to your questions:
For your scenario of Absent/Present in one plot, you may be able to use a single two-column plot to represent what you want, by rearranging the data. I'm not sure what the current arrangement looks like, but assuming you have two columns like:
You can plot this with |
Thanks @znation for the help. It won't allow me to attach a spreadsheet but here is a jpeg (it is very basic to recreate) When I run the code import turicreate as tc I get the error I listed above. When I use the code you supplied: import turicreate as tc It does open Turi Create Visualize and plot the x and y axis, place the dates and attendance but does not actually plot the content. |
@radikal9 In the meantime you can probably work around this by using another library to generate the chart you're looking for, with the data from the SFrame. Something like this (using matplotlib below): import numpy as np
import matplotlib.pyplot as plt
ind = np.arange(len(sf))
width = 0.2
p1 = plt.bar(ind, list(sf['Present']), width, color='blue')
p2 = plt.bar(ind, list(sf['Absent']), width, color='red', bottom=list(sf['Present']))
plt.title('Attendance by Date')
plt.xticks(ind, list(sf['Date']))
plt.yticks(np.arange(0, 23, 5))
plt.legend((p1[0], p2[0]), ('Present', 'Absent'))
plt.show() |
Without this fix, a user passing the wrong data type to `plot` would get a cryptic error message like: ```python ----> 1 tc.show('date', 'temp') /Users/zach/turicreate/debug/src/python/turicreate/visualization/show.py in show(x, y, xlabel, ylabel, title) 141 142 """ --> 143 plot(x, y, xlabel, ylabel, title).show() 144 145 def scatter(x, y, xlabel=LABEL_DEFAULT, ylabel=LABEL_DEFAULT, title=LABEL_DEFAULT): /Users/zach/turicreate/debug/src/python/turicreate/visualization/show.py in plot(x, y, xlabel, ylabel, title) 78 """ 79 title = _get_title(title) ---> 80 plt_ref = tc.extensions.plot(x, y, xlabel, ylabel, title) 81 return Plot(_proxy=plt_ref) 82 /Users/zach/turicreate/debug/src/python/turicreate/extensions.pyc in <lambda>(*args, **kwargs) 168 169 def _make_injected_function(fn, arguments): --> 170 return lambda *args, **kwargs: _run_toolkit_function(fn, arguments, args, kwargs) 171 172 def _class_instance_from_name(class_name, *arg, **kwarg): /Users/zach/turicreate/debug/src/python/turicreate/extensions.pyc in _run_toolkit_function(fnname, arguments, args, kwargs) 157 if not ret[0]: 158 if len(ret[1]) > 0: --> 159 raise _ToolkitError(ret[1]) 160 else: 161 raise _ToolkitError("Toolkit failed with unknown error") ToolkitError: Variant type error: Expecting SArray but got a flexible_type ``` Fixes #141
When I use turicreate.show to create a graph:
turicreate.show("Date", "Present")
With x=Date and y=Present ('Date' and 'Present' are columns in the spreadsheet attendance.csv) I get the following error:
Finished parsing file /Users/mobile/Attendance.csv
Parsing completed. Parsed 94 lines in 0.008757 secs.
Traceback (most recent call last):
File "/Users/mobile/Attendance.py", line 4, in
turicreate.show("Date", "Present")
File "/Users/mobile/anaconda/lib/python2.7/site-packages/turicreate/visualization/show.py", line 75, in show
return tc.extensions.show(path_to_client, x, y, xlabel, ylabel, title)
File "/Users/mobile/anaconda/lib/python2.7/site-packages/turicreate/extensions.py", line 168, in
return lambda *args, **kwargs: _run_toolkit_function(fn, arguments, args, kwargs)
File "/Users/mobile/anaconda/lib/python2.7/site-packages/turicreate/extensions.py", line 157, in _run_toolkit_function
raise _ToolkitError(ret[1])
turicreate.toolkits._main.ToolkitError: boost::bad_get: failed value get using boost::get
Adding an xlabel, ylabel and title returned the same error.
Also, from the documentation it seems that the type of chart that will be returned is based on the number of lines in the document and type of content that is in the cell. Is there any way to add it the ability to select the graph type (obviously limited to the type of content).
Finally, is there a way to add more than one set of data to a chart axis? For instance, in this case we have school attendance logs. I want to be able to plot the "Date" on the X axis and then on the Y axis show to factors "Present" (those who are at school) and "Absent"
Thanks
The text was updated successfully, but these errors were encountered: