Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

turicreate.show bad_get error #141

Closed
radikal9 opened this issue Dec 26, 2017 · 4 comments · Fixed by #2185
Closed

turicreate.show bad_get error #141

radikal9 opened this issue Dec 26, 2017 · 4 comments · Fixed by #2185

Comments

@radikal9
Copy link

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

@znation
Copy link
Contributor

znation commented Dec 26, 2017

@radikal9 Can you upload the attendance.csv file in this issue, or another CSV file that reproduces this issue? I haven't seen this issue with any dataset I've tried so far.

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:

Columns:
	Date	str
	Attendance	str

Rows: 3

Data:
+----------+------------+
|   Date   | Attendance |
+----------+------------+
| 12/01/17 |   Absent   |
| 12/02/17 |  Present   |
| 12/03/17 |  Present   |
+----------+------------+
[3 rows x 2 columns]

You can plot this with tc.show(sf['Date'], sf['Attendance']). If this isn't what you had in mind, please clarify what kind of plot you're looking for and there may be a workaround to get it without adding support for multiple series per axis. Hope that helps!

@radikal9
Copy link
Author

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)

screen shot 2017-12-26 at 4 39 14 pm

When I run the code

import turicreate as tc
sf = tc.SFrame('/Users/name/Attendance.csv')
tc.show('Date', 'Present')

I get the error I listed above.

When I use the code you supplied:

import turicreate as tc
sf = tc.SFrame('/Users/name/Attendance.csv')
tc.show(sf['Date'], sf['Present'])

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.

screen shot 2017-12-26 at 4 33 11 pm

@znation
Copy link
Contributor

znation commented Dec 27, 2017

Thanks @radikal9, I am keeping this issue to track bad_get and I opened #144 to track the box plot failing to render with this data.

@znation
Copy link
Contributor

znation commented Dec 27, 2017

@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()

@afranklin afranklin added 1801 and removed 1801 labels Feb 6, 2018
@znation znation added 1803 and removed 1802 labels Mar 12, 2018
@znation znation removed the 1803 label Apr 10, 2018
@znation znation removed their assignment Jun 20, 2018
@afranklin afranklin added the p3 label Jun 27, 2018
@znation znation removed the 1807 label Jul 30, 2018
znation pushed a commit that referenced this issue Aug 11, 2019
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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants