Google Colaboratory provides a convenient Jupyter Notebooks-like environment that I actively use. Often, my data sources are located on Google Drive. To use them, there is an easy way to do so by mounting a folder on Google Drive to your Colab Notebook:

# 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:

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:

path = 'gdrive/My Drive/Colab Notebooks/datasets/pandas_manual/'

To use a file named data.csv just use:

import pandas as pd
data = pd.read_csv(path + 'data.csv')
Categories: PandasPython

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *