Skip to content

Instantly share code, notes, and snippets.

@atyrachma
Last active June 12, 2021 04:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atyrachma/98e7b0b1122cc85731b4d2d12efaad2a to your computer and use it in GitHub Desktop.
Save atyrachma/98e7b0b1122cc85731b4d2d12efaad2a to your computer and use it in GitHub Desktop.
py-import-to-colab.py
#from kaggle
# Colab library to upload files to notebook
from google.colab import files
# Install Kaggle library
!pip install -q kaggle
#update dulu
!pip install kaggle --upgrade
# Upload kaggle API key file
uploaded = files.upload()
##for fn in uploaded.keys():
## print('User uploaded file "{name}" with length {length} bytes'.format(
## name=fn, length=len(uploaded[fn])))
# Then move kaggle.json into the folder where the API expects to find it.
!mkdir -p ~/.kaggle/ && mv kaggle.json ~/.kaggle/ && chmod 600 ~/.kaggle/kaggle.json
# Downlaod data from past challenge
!kaggle --version
!kaggle competitions download -c shopee-sentiment-analysis --force
import pandas as pd
# Import the test and train datasets into pandas dataframe
df_train = pd.read_csv('train.csv.zip', compression='zip', header=0, sep=',', quotechar='"')
df_test = pd.read_csv('test.csv.zip', compression='zip', header=0, sep=',', quotechar='"')
import numpy as np
np.size(df_train) #clear
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment