Getting started with Google Colab
My regular little chit chats
Does technology distract you? As far as I am concerned, the answer is yes. I decided to upskill when I lost a job in 2018. Since then, I have been with Udacity. First I did a Nano Degree in Data and when I was half way through, I got a scholarship through Udacity’s Google India Scholarship 2018 program. Since then, I have lost my focus and I keep shuttling between Data and Android. I recently got another scholarship, which is the Bertelesmann Scholarship, but, considering the advices of my well-wishers, I have finally decided to let go of the scholarship and focus on Android alone.
But yeah, I have this problem. I take up some or other things in tech and it demands a change of focus. When India is in the mid of the lockdown due to Covid 19, I too decided to touch a bit of data again as part of a small work that I am doing. Now, that made me touch on Google Colab again and this long pending blog, I thought I will complete today.
I had attended Ms.Usha Rangaraju’s session on Colab sometime back through GDG, the only one which I attended with GDG Bangalore. It was a good one and I wanted to keep some notes for myself and this blog was pending since then.
Why Google Colab
Today, I have a set of excel files with me. As always, the more the number of excel files we work on, the more it becomes difficult to manage things at a later stage. When we want to get a feel of the data and want to try manipulating them, the best option is always to bring it on a data frame using pandas in python. I had lost touch with Python completely and wanted to have a ready set up to do this. That is when I remembered about Colab again.
To the topic:
Here is what you could do to get started with Google Colab.
- Search for “Google Colab” on Google. Find the link corresponding to https://colab.research.google.com/ and login with your gmail account
Step 2 - Upload the required files as .csv onto Google Drive. In the above, you can see that my files are on My Drive->ColabDemo folder
Step 3 — Create a new Notebook. Use the File Menu — New Notebook option (picture attached below)
Step 4 — Tadang! The notebook is ready to use! Rename the notebook to have the name you like to have. Run the python code like using a usual jupyter note book.
To import a set of files which are there on the drive, do the below:
(I had in fact forgotten, how to do this. I found this on stack overflow here: https://stackoverflow.com/questions/48340341/read-csv-to-dataframe-in-google-colab)
Run the below code on the first cell of the notebook, follow the instructions and complete the authentication.
from google.colab import drivedrive.mount('/content/gdrive/')
On successful authentication, you get an output which looks like the below.
Woohoo… We have a good platform to start playing with our files now.
Step 6 — Add the next cell as usually done on a Jupyter Notebook by clicking on the “+ Code”
Time to bring in our favorite Pandas. :) Below is a code that I have pasted for reference.
import pandas as pddf=pd.read_csv('gdrive/My Drive/ColabDemo/class 3A.csv')df.head()
Let us now view the output before we close the session.
I hope you like the blog. :)