I can\'t get the following python code to run with errors. Can you please tell m
ID: 2246891 • Letter: I
Question
I can't get the following python code to run with errors. Can you please tell me how to fix the error?
Here is the error message that I get:
Here is the code:
In [2]: runfile('C:/Users/schwe/Desktop/Lab1.py', wdir-'C:/Users/schwe/Desktop') Traceback (most recent call last): File "", line 1, in runfile('C:/users/schwe/Desktop/Lab1.py', wdr= 'C : /Users/schwe/Desktop") File "C:Users schwe Anaconda3liblsite-packages spyderlutilslsitelsitecustomize.py", line 880, in runfile File "C:Users schwe Anaconda3liblsite-packages spyderlutilslsitelsitecustomize.py", line 102, in execfile File "C:/Users/schwe/Desktop/Lab1.py", line 72, in File "C:Usersschwe'Anaconda3libisite-packagespandascore'series.py", line 227, in-init- execfile(filename, namespace) exec (compile(f.read), filename, 'exec, namespace) mySeries_fromSet-pd.Series('databases', 2017}) "", format (data. class -.-name-) ) TypeError: 'set' type is unorderedExplanation / Answer
Solution==========================
The method "pd.Series", expects data as its parameter to be "in Series/Order" like array , vector etc. "Set" however is an un-ordered list (having no particular sqeuence or Order). Thus, in order to use "Series" on set, convert it to a list:
mySeries_fromSet=pd.Series(list({'databases',2017}))
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.