Runtime error in apply() function of python - python

I am doing a ML course on Coursera
When I run the following command
sf['Country'] = sf['Country'].apply(transform_country)
Following is the error i get
RuntimeError Traceback (most recent call last)
<ipython-input-10-e97a176c3eea> in <module>()
----> 1 sf['Country'] = sf['Country'].apply(transform_country)
F:\Anaconda2\envs\gl-env\lib\site-packages\graphlab\data_structures\sarray.pyc in apply(self, fn, dtype, skip_undefined, seed)
1892
1893 with cython_context():
-> 1894 return SArray(_proxy=self.__proxy__.transform(fn, dtype, skip_undefined, seed))
1895
1896
F:\Anaconda2\envs\gl-env\lib\site-packages\graphlab\cython\context.pyc in __exit__(self, exc_type, exc_value, traceback)
47 if not self.show_cython_trace:
48 # To hide cython trace, we re-raise from here
---> 49 raise exc_type(exc_value)
50 else:
51 # To show the full trace, we do nothing and let exception propagate
RuntimeError: Runtime Exception. Cannot evaluate lambda. Lambda workers cannot not start.
What do I do now ?

Related

maximum recursion depth exceeded google colab

Trying to run some python code on Google colab. I have some preprocessed data that I need to read in:
train, test, unused_feat, target_features, features, cat_idxs, cat_dims = pickle.load(open('/content/drive/My Drive/xxx/data/train_test.pkl', 'rb'))
Then if I call train I get the error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/IPython/core/formatters.py in __call__(self, obj)
697 type_pprinters=self.type_printers,
698 deferred_pprinters=self.deferred_printers)
--> 699 printer.pretty(obj)
700 printer.flush()
701 return stream.getvalue()
8 frames
pandas/_libs/properties.pyx in pandas._libs.properties.AxisProperty.__get__()
/usr/local/lib/python3.6/dist-packages/pandas/core/generic.py in __getattr__(self, name)
5268 or name in self._accessors
5269 ):
-> 5270 return object.__getattribute__(self, name)
5271 else:
5272 if self._info_axis._can_hold_identifiers_and_holds_name(name):
AttributeError: 'DataFrame' object has no attribute '_data'
and when I call
---------------------------------------------------------------------------
RecursionError Traceback (most recent call last)
<ipython-input-35-5e6a15ce28a5> in <module>()
----> 1 train.shape
321 frames
pandas/_libs/properties.pyx in pandas._libs.properties.AxisProperty.__get__()
/usr/local/lib/python3.6/dist-packages/pandas/core/generic.py in __getattr__(self, name)
5268 or name in self._accessors
5269 ):
-> 5270 return object.__getattribute__(self, name)
5271 else:
5272 if self._info_axis._can_hold_identifiers_and_holds_name(name):
RecursionError: maximum recursion depth exceeded while calling a Python object
When I work on my own jupyter notebook I have no problem with this. I wonder what went wrong. Also train contains roughly 250000 rows.
I think you could change the recursion limit if that is your constraint, however, you might be in an endless loop.
This post tells you how to increase your recursion limit.
What is the maximum recursion depth in Python, and how to increase it?
However, I am not sure about the other error you got. Hope it helps a bit.

Change in JModelica transfer_optimization_problem method?

I believe that there has been a change in the JModelica transfer_optimization_problem method that is not documented. If there is a new way of doing this, I'd like to know as I am new to JModelica. I am following the manual for JModelica 2.2 and I noticed that
from pyjmi import transfer_optimization_problem
does not exist, but this does:
from pyjmi.casadi_interface import transfer_optimization_problem
But this line returns an error:
op = transfer_optimization_problem("VDP_Opt", "VDP_Opt.mop")
The error:
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
<ipython-input-27-e1ed8260993b> in <module>()
----> 1 op = transfer_optimization_problem("VDP_Opt", "VDP_Opt.mop")
/home/paperspace/JModelica/Python/pyjmi/casadi_interface.py in transfer_optimization_problem(class_name, file_name, compiler_options, compiler_log_level, accept_model)
147
148 """
--> 149 op = OptimizationProblem()
150 _transfer_optimization_problem(op, class_name=class_name, file_name=file_name,
151 compiler_options=compiler_options,
/home/paperspace/JModelica/Python/pyjmi/common/core.py in __init__(self)
44
45 def __init__(self):
---> 46 raise Exception("This is an abstract class it can not be instantiated.")
47
48 def optimize(self):
Exception: This is an abstract class it can not be instantiated.

Google AdManager getCurrentNetwork() error

I have set up ad manager credentials. I'm trying to access the Admanager API, im getting the following error.
from googleads import ad_manager
client = ad_manager.AdManagerClient.LoadFromStorage()
network_service = client.GetService('NetworkService', version='v201902')
current_network = network_service.getCurrentNetwork()
the error im facing is:
Fault Traceback (most recent call last)
~\Anaconda3\lib\site-packages\googleads\common.py in MakeSoapRequest(*args)
1381 return soap_service_method(
-> 1382 *packed_args, _soapheaders=soap_headers)['body']['rval']
1383 except zeep.exceptions.Fault as e:
~\Anaconda3\lib\site-packages\zeep\proxy.py in __call__(self, *args, **kwargs)
41 self._proxy._client, self._proxy._binding_options,
---> 42 self._op_name, args, kwargs)
43
~\Anaconda3\lib\site-packages\zeep\wsdl\bindings\soap.py in send(self, client, options, operation, args, kwargs)
131
--> 132 return self.process_reply(client, operation_obj, response)
133
~\Anaconda3\lib\site-packages\zeep\wsdl\bindings\soap.py in process_reply(self, client, operation, response)
193 if response.status_code != 200 or fault_node is not None:
--> 194 return self.process_error(doc, operation)
195
~\Anaconda3\lib\site-packages\zeep\wsdl\bindings\soap.py in process_error(self, doc, operation)
287 actor=None,
--> 288 detail=etree_to_string(doc))
289
Fault: Unknown fault occured
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
<ipython-input-16-991c0839fc99> in <module>()
----> 1 current_network = network_service.getCurrentNetwork()
~\Anaconda3\lib\site-packages\googleads\common.py in MakeSoapRequest(*args)
1385 if e.detail is not None:
1386 underlying_exception = e.detail.find(
-> 1387 '{%s}ApiExceptionFault' % self._GetBindingNamespace())
1388 fault_type = self.zeep_client.get_element(
1389 '{%s}ApiExceptionFault' % self._GetBindingNamespace())
TypeError: a bytes-like object is required, not 'str'
You are probably missing permissions with your configured service account. Make sure the account has access to ad-manager and scopes are configured properly.
I suggest to do it this way:
class Adx:
def __init__(self):
self.GOOGLEADS_YAML = 'googleads.yaml'
self.GOOGLEADS_VERSION = 'v202111'
self.google_keys = self.GOOGLEADS_YAML
def activate(self):
ad_manager_client = ad_manager.AdManagerClient.LoadFromStorage(self.google_keys)

Cannot load graphlab.sframe

I have joined Machine Learning course on coursera. I am facing an issue while executing following command:
sales = graphlab.SFrame('home_data.gl/')
THe error is as follows:
IOError Traceback (most recent call last)
<ipython-input-9-e5b5a1ead746> in <module>()
----> 1 sales = graphlab.SFrame('home_data.gl')
C:\Users\admin\Anaconda2\envs\gl-env\lib\site-packages\graphlab
\data_structures\sframe.pyc in __init__(self, data, format, _proxy)
951 pass
952 else:
--> 953 raise ValueError('Unknown input type: ' + format)
954
955 sframe_size = -1
C:\Users\admin\Anaconda2\envs\gl-env\lib\site-packages\graphlab\cython\context.pyc in __exit__(self, exc_type, exc_value, traceback)
47 if not self.show_cython_trace:
48 # To hide cython trace, we re-raise from here
---> 49 raise exc_type(exc_value)
50 else:
51 # To show the full trace, we do nothing and let exception propagate
IOError: Cannot open C:/Users/admin/home_data.gl/dir_archive.ini for read. Cannot open C:/Users/admin/home_data.gl/dir_archive.ini for reading
Can you please help me to resolve this issue?
Go to terminal and run:
unzip home_data.gl.zip
You will see following files in directory home_data.gl:
Now in ipython, run:
sales = graphlab.SFrame('home_data.gl/')
sales
which will display the data in tabular format:

scikit-learn optionparser error

From the classification example on the website of scikit-learn, I'm getting the following error after executing the part with optionparser:
Usage: __main__.py [options]
__main__.py: error: no such option: -f
An exception has occurred, use %tb to see the full traceback.
SystemExit: 2
To exit: use 'exit', 'quit', or Ctrl-D.
a %tb command gives the following output:
---------------------------------------------------------------------------
BadOptionError Traceback (most recent call last)
/Users/kevinoost/anaconda/lib/python3.5/optparse.py in parse_args(self, args, values)
1385 try:
-> 1386 stop = self._process_args(largs, rargs, values)
1387 except (BadOptionError, OptionValueError) as err:
/Users/kevinoost/anaconda/lib/python3.5/optparse.py in _process_args(self, largs, rargs, values)
1429 # value(s) for the last one only)
-> 1430 self._process_short_opts(rargs, values)
1431 elif self.allow_interspersed_args:
/Users/kevinoost/anaconda/lib/python3.5/optparse.py in _process_short_opts(self, rargs, values)
1511 if not option:
-> 1512 raise BadOptionError(opt)
1513 if option.takes_value():
BadOptionError: no such option: -f
During handling of the above exception, another exception occurred:
SystemExit Traceback (most recent call last)
<ipython-input-10-960f3b27132a> in <module>()
66 "headers, signatures, and quoting.")
67
---> 68 (opts, args) = op.parse_args()
69 if len(args) > 0:
70 op.error("this script takes no arguments.")
/Users/kevinoost/anaconda/lib/python3.5/optparse.py in parse_args(self, args, values)
1386 stop = self._process_args(largs, rargs, values)
1387 except (BadOptionError, OptionValueError) as err:
-> 1388 self.error(str(err))
1389
1390 args = largs + rargs
/Users/kevinoost/anaconda/lib/python3.5/optparse.py in error(self, msg)
1566 """
1567 self.print_usage(sys.stderr)
-> 1568 self.exit(2, "%s: error: %s\n" % (self.get_prog_name(), msg))
1569
1570 def get_usage(self):
/Users/kevinoost/anaconda/lib/python3.5/optparse.py in exit(self, status, msg)
1556 if msg:
1557 sys.stderr.write(msg)
-> 1558 sys.exit(status)
1559
1560 def error(self, msg):
SystemExit: 2
According to the docs, optparse was deprecated in version 2.7 of Python; and I am using Python 3.
What do I do to fix this?
Thank you,
Regards, Kevin

Categories

Resources