Three Noticeable Difference of Colab and Spyder for a Beginner
A Test of Friendship
For this project, I will be creating a short quiz that my close friends can answer. You can say its a Test of Friendship quiz. They will be answering things about my college crush. If they are truly my friend then they will remember that crush. Why my crush? Because it is fun to reminisce about college crushes just like in movies! Surely my friends can remember some funny moments associated with that so even if I am staking my dignity for this quiz its all good.
I will be doing this quiz in two versions. One in Colab and the other in Spyder. In this quiz, I will examine the three(3) things I notice that is so different from Colab and Spyder. These three things are something that made pause and think before executing my code.
If you want the link of the codes on how I made this quiz you may check the Colab sample here. If you wanna see the Spyder version click here. To get the CSV file I used for this project, click here.
How to upload your file
As you can see for Colab you need to run the file.upload() function to import the file from your local to Colab. While for Spyder, you need to copy and paste the file to the folder where your .py file is located. You can see that in the file explorer of Spyder as show in the image above. This hugely different approach is confusing for someone who had never used Colab because the file.upload() seems to be an exclusive function for Colab only.
We should also note that Colab is web/cloud hosted and its using cloud computing to execute the codes. This means, if we want a file to be read we would need to upload it somewhere in the cloud where Colab can read it. While, Spyder is locally hosted and it is using your computer’s resources to execute. More so, it can find the files locally as Spyder and the file lived in the same universe.
Showing the Header of the Dataframe
If you want to show the header of your Dataframe, for Colab you simply use the Datadframe.head() function and run. Colab will immidiately show the header. But for Spyder, you need to use the print() function to show the result of the Datadframe.head() function. Seems like in Spyder, I will need to use print() function more to display results.
It is a good thing to keep this in mind in running codes in Spyder as you may find yourself asking if your codes works or not because nothing shows. Just like me!
Running a piece of code
Running a snippet of code in Colab is simple, you just need to run it in a separate cell. Colab will run everything written in the cell, you can run as many codes or as little in the cell. For Spyder, you will need to highlight and click run. You can highlight as many lines as you want to run.
By the way running a code does not mean it will function. Might be that when you run one line or one cell you will encounter an error. But this method is quite good in isolating an issue to figure out either how things function or why an error occurs. Of course, there are other debugging methods you can use not just this one.
For now, those are the three things I notice that is so different when I am using Colab and Spyder. Please let me know in the comments if you notice something else so that I can pay attention to it next time. Also, maybe suggest some fun things as a project. It is easier to learn when you find some fun and purpose to it. Thanks!