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 *

This website uses cookies

The website Singular Aspect that belongs to the projects of DivisionLab UG (haftungsbeschränkt) uses cookies and other technologies so that this site can run reliably and securely, can measure its performance, and show you relevant content and personalized offers. In order for this to work, the website collects data about its users and how they use the website's offers on which devices.

If you click "Accept all", you agree and allow us to share this information with third parties, such as our marketing partners. This may include the processing of your data outside the USA (including but mot limited to, Germany). If you do not agree to this, we limit ourselves to the essential cookies and you must be aware that our content will not be tailored to you. Further details and all options can be found in the "Settings". You can also adjust these later at any time. You can find more information in our data protection declaration. Cookies and privacy.