Skip to content

Commit e4ad3f4

Browse files
DOC: add Google Colab data loading section
1 parent 1fd184d commit e4ad3f4

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

doc/source/user_guide/io.rst

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6520,3 +6520,45 @@ The files ``test.pkl.compress``, ``test.parquet`` and ``test.feather`` took the
65206520
24009288 Oct 10 06:43 test_fixed_compress.hdf
65216521
24458940 Oct 10 06:44 test_table.hdf
65226522
24458940 Oct 10 06:44 test_table_compress.hdf
6523+
6524+
Loading data in Google Colab
6525+
'''''''''''''''''''''''''''
6526+
6527+
Google Colab is a hosted Jupyter notebook environment. Since it runs remotely,
6528+
files must be explicitly uploaded or mounted before they can be read by pandas.
6529+
6530+
Uploading local files
6531+
~~~~~~~~~~~~~~~~~~~~~
6532+
6533+
Files can be uploaded directly to the Colab runtime using ``google.colab.files``:
6534+
6535+
.. code-block:: python
6536+
6537+
from google.colab import files
6538+
uploaded = files.upload()
6539+
6540+
import pandas as pd
6541+
df = pd.read_csv("data.csv")
6542+
6543+
Using Google Drive
6544+
~~~~~~~~~~~~~~~~~~
6545+
6546+
Google Drive can be mounted to make files available to the runtime:
6547+
6548+
.. code-block:: python
6549+
6550+
from google.colab import drive
6551+
drive.mount("/content/drive")
6552+
6553+
import pandas as pd
6554+
df = pd.read_csv("/content/drive/MyDrive/data.csv")
6555+
6556+
Loading data from a URL
6557+
~~~~~~~~~~~~~~~~~~~~~~
6558+
6559+
Data hosted remotely can be read directly using a URL:
6560+
6561+
.. code-block:: python
6562+
6563+
import pandas as pd
6564+
df = pd.read_csv("https://example.com/data.csv")

0 commit comments

Comments
 (0)