Using Google Drive as a filesystem in Google Colab¶
Mount Google Drive¶
In [ ]:
Copied!
from google.colab import drive
drive.mount('/content/gdrive')
from google.colab import drive
drive.mount('/content/gdrive')
Mounted at /content/gdrive
Basic Linux commands¶
Prefixing a command with "!" will allow for commands to be sent directly to the operating system underneath. Which is a linux machine.
In [1]:
Copied!
!pwd
!pwd
/content
In [ ]:
Copied!
!ls
!ls
gdrive sample_data
In [ ]:
Copied!
!ls '/content/gdrive/MyDrive/Marquins Colab Notebooks/Intro to Google Colab training'
!ls '/content/gdrive/MyDrive/Marquins Colab Notebooks/Intro to Google Colab training'
00_intro_to_colab.ipynb 01_using_google_drive_as_a_filesystem.ipynb 02_reading_and_saving_to_google_sheets.ipynb 03_pulling_data_from_Adobe_analytics.ipynb '04_querying BigQuery.ipynb' iris.csv Misc.ipynb prem_data.gsheet 'Welcome To Colaboratory [MS copy]'
Load a csv file that is saved on Google Drive¶
In [ ]:
Copied!
import pandas as pd
import pandas as pd
In [ ]:
Copied!
data = pd.read_csv('/content/gdrive/MyDrive/Marquins Colab Notebooks/Intro to Google Colab training/iris.csv')
data = pd.read_csv('/content/gdrive/MyDrive/Marquins Colab Notebooks/Intro to Google Colab training/iris.csv')
In [ ]:
Copied!
data.head()
data.head()
Out[ ]:
sepal_length | sepal_width | petal_length | petal_width | species | |
---|---|---|---|---|---|
0 | 5.1 | 3.5 | 1.4 | 0.2 | Iris-setosa |
1 | 4.9 | 3.0 | 1.4 | 0.2 | Iris-setosa |
2 | 4.7 | 3.2 | 1.3 | 0.2 | Iris-setosa |
3 | 4.6 | 3.1 | 1.5 | 0.2 | Iris-setosa |
4 | 5.0 | 3.6 | 1.4 | 0.2 | Iris-setosa |
Basic interactive filtering¶
In [ ]:
Copied!
%load_ext google.colab.data_table
%load_ext google.colab.data_table
In [ ]:
Copied!
data
data
Out[ ]:
sepal_length | sepal_width | petal_length | petal_width | species | |
---|---|---|---|---|---|
0 | 5.1 | 3.5 | 1.4 | 0.2 | Iris-setosa |
1 | 4.9 | 3.0 | 1.4 | 0.2 | Iris-setosa |
2 | 4.7 | 3.2 | 1.3 | 0.2 | Iris-setosa |
3 | 4.6 | 3.1 | 1.5 | 0.2 | Iris-setosa |
4 | 5.0 | 3.6 | 1.4 | 0.2 | Iris-setosa |
... | ... | ... | ... | ... | ... |
145 | 6.7 | 3.0 | 5.2 | 2.3 | Iris-virginica |
146 | 6.3 | 2.5 | 5.0 | 1.9 | Iris-virginica |
147 | 6.5 | 3.0 | 5.2 | 2.0 | Iris-virginica |
148 | 6.2 | 3.4 | 5.4 | 2.3 | Iris-virginica |
149 | 5.9 | 3.0 | 5.1 | 1.8 | Iris-virginica |
150 rows × 5 columns
In [ ]:
Copied!