User 2419 | 10/15/2015, 9:26:37 PM
I have used the function defined below (awesome_count) on a dictionary type array series in the products SFrame for the 2nd assignment. Below is the code I used
> def awesome_count(dicto): > if 'awesome' in dicto: > return dicto.count('awesome') > else: > return 0 > > > # test function awesome_count on a single cell > awesome_count(products['word_count']) > ># use function awesome_count on SArray in SFrame products > products['awesome'] = products['word_count'].apply(awesome_count)
The output of the code is as follows:
RuntimeError Traceback (most recent call last) <ipython-input-37-2918ee116b28> in <module>() 9 #products['awesome'] = products['word_count'].apply(lambda x: dict(x) if 'awesome' in x else 0) 10 ---> 11 products['awesome'] = products['wordcount'].apply(awesomecount) 12 13 #wordcountorig = products['word_count']
C:\Users\Gokul\AppData\Local\Dato\Dato Launcher\lib\site-packages\graphlab\datastructures\sarray.pyc in apply(self, fn, dtype, skipundefined, seed) 1624 1625 with cythoncontext(): -> 1626 return SArray(proxy=self.proxy.transform(fn, dtype, skip_undefined, seed)) 1627 1628
C:\Users\Gokul\AppData\Local\Dato\Dato Launcher\lib\site-packages\graphlab\cython\context.pyc in exit(self, exctype, excvalue, traceback) 47 if not self.showcythontrace: 48 # To hide cython trace, we re-raise from here ---> 49 raise exctype(excvalue) 50 else: 51 # To show the full trace, we do nothing and let exception propagate
RuntimeError: Runtime Exception. The system cannot find the file specified.
I am unable to proceed further without utilizing the apply() function in this instance. I have exported the products SFrame into a csv and performed the same operation in a pandas dataframe in Anaconda, and it worked (except that the dataframe lost its dict attributes as it was saved into a csv).
Could you please help?