初めてGoogleColabを使用します。Kaggle APIを使用し、データをGoogle Colabにロードしましたが、パンダ経由で開くことができないようです。ファイルを右クリックしてパスをコピーしました。次に、次のコードを実行しました。
import pandas as pd
train = pd.read_csv("content/train.csv")
test = pd.read_csv('content/test.csv')
私が得ているエラーコード:
FileNotFoundError: File b'content/train.csv' does not exist
このエラーに至るまでに私が行ったすべてのコードは次のとおりです。
!pip install kaggle
from google.colab import files
files.upload() #Uploaded my kaggle.json file
!pip install -q kaggle
!mkdir -p ~/.kaggle
!cp kaggle.json ~/.kaggle/
!kaggle competitions download -c microsoft-malware-prediction
#Unzip the files:
!7z x train.csv.zip
!7z x sample_submission.csv.zip
!7z x test.csv.zip
#remove the zipped data
!rm train.csv.zip
!rm sample_submission.csv.zip
!rm test.csv.zip
import pandas as pd
train = pd.read_csv("content/train.csv")
test = pd.read_csv('content/test.csv')
print('read')
どんな助けでも素晴らしいでしょう!
!pip install -U -q PyDrive
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from google.colab import auth
from oauth2client.client import GoogleCredentials
#Authenticate and create the PyDrive client
auth.authenticate_user()
gauth = GoogleAuth()
gauth.credentials = GoogleCredentials.get_application_default()
drive = GoogleDrive(gauth)
link = 'link_to_file_in drive'
fluff, id = link.split('=')
downloaded = drive.CreateFile({'id':id})
downloaded.GetContentFile('name_of_file.csv')
df = pd.read_csv("name_of_file.csv")
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加