I can\'t get the following python code to run with errors. Can you please tell m
ID: 2246698 • 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
The error is in this line :-
mySeries_fromSet = pd.Series( { 'databases ' , 2017 } )
Set are unordered data structure so we might not get the exact order in the way we entered the values, So hence the error.
You need to remove that line
And remember Tuple cannot be modified as they are light weight list. Inorder to modify them we need to concert it back to list and then convert it back to Tuple.
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.