Loading Data in Colab
Loading Data in Colab
This option will create a “Choose File” button in your notebook, using which you can upload
This will add a “Choose Files” button and you can upload your dataset. files.upload returns a
dictionary of the files which were uploaded. The dictionary is keyed by the file name, the
value is the data which was uploaded. Note that the uploaded file object is encoded so we
have to decode it before use.
Using pandas to store the uploaded csv file into a DataFrame.
import pandas as pd
import io
train_data = pd.read_csv(io.StringIO(uploaded['train.csv'].decode('utf-8')))
import pandas as pd
import io
data = pd.read_excel(io.BytesIO(uploaded['Online_Retail.xlsx']))
drive.mount('/content/gdrive')
It will ask for a authorisation code through a link. after signing into your Google account get the
test_data = pd.read_csv('/content/gdrive/My Drive/Taxi_Trips.csv')