Google Colaboratory provides a convenient Jupyter Notebooks-like environment that I actively use. Often, my data sources are located on a Google drive. To use them, there is an easy way to do so by mounting a folder on Google Drive to your Colab Notebook:
1 2 3 4 |
# Mount google drive from google.colab import drive drive.mount('/content/gdrive') |
You will see an invitation to authorize the Notebook access to your Google Drive:
1 2 3 4 5 |
Go to this URL in a browser: https://accounts.google.com/o/oauth2/auth?client_id=... Enter your authorization code: ·········· Mounted at /content/gdrive |
Finally, you can define a variable pointing to the folder with your data files:
1 |
path = 'gdrive/My Drive/Colab Notebooks/datasets/pandas_manual/' |
To use a file named data.csv
just use:
1 2 |
import pandas as pd data = pd.read_csv(path + 'data.csv') |
