In our course of Data Mining, at the University of Pisa, the teacher uses Jupyter. Jupyter is a notebook where you can write some code, execute it and then see the output directly below the code, in the same page. It is a very powerful tool that speeds up the coding phase and helps people that are not familiar with the terminal to code in a “familiar” space.
The main problem is that Jupyter is complex to configure, to change from Python 2.7 to 3 you have to install packets, do stuff with the terminal, download bytes on your disk and so on… Moreover, if you would like to share the notebook with your colleague you have to do some special trick: install jupyter on your server, activate multiuser mode, invest hours of your time because it will not works…
But there is a solution: Google CoLab
It is like a Jupyter, more minimal but has:
- Python 2.7 and 3 are available and both are ready to use
- You can share it like any other Google Docs file, simply generating a link and send it
- It is in the cloud, you can use it anywhere
- It supports hardware acceleration
- It can execute python on your machine or on hosted one
- It can access your Google Drive account with few lines of code
Python 2.7 or 3
You can simply change the runtime type selecting “Runtime” from the main menu, then “Change runtime type”. No other installations are required!
Share the notebook
You should be familiar with this feature
Execute on your machine
Here some more configurations have to be done. If you would like to execute code on your machine you have to install Jupyter, then have to activate the
jupyter_http_over_ws jupyter extension then start the server. https://research.google.com/colaboratory/local-runtimes.html.
Access to file
In order access to some files you can:
- Connect to Google Drive
from google.colab import drive drive.mount('/content/drive')
- Upload files on the temporary local drive
- Download the file from a Gist
import requests url="https://gist.githubusercontent.com/..../file.txt" s=requests.get(url).content df=pd.read_csv(io.StringIO(s.decode('utf-8')))