Google Colabo 설정 및 데이터 읽기
7570 단어 colaboratory
구글 드라이브 마운트
from google.colab import drive
drive.mount('/content/drive')
!ls drive/MyDrive/
구글 드라이브의 데이터 읽기import pandas as pd
df = pd.read_csv('drive/MyDrive/ML/Pytorch-sample-luna/luna_sample_candidates.csv')
구글 드라이브의python 모듈 읽기ROOT_PATH = 'drive/MyDrive/ML/pytorch-sample-luna/'
sys.path.append(ROOT_PATH)
import dsets
드라이브에 외부 데이터 직접 다운로드!wget -P 'drive/MyDrive/ML/pytorch-sample-luna/' 'https://zenodo.org/record/3723295/files/annotations.csv?download=1'
설정Google Colaboratory App 추가
왼쪽 위의 "새로 만들기"> "기타"> "응용 프로그램 추가"에 응용 프로그램을 추가합니다.(첨부 파일에 추가됨)


입출력 주변
Google Drive 및 Colab 통합
mount
from google.colab import drive
drive.mount('/content/drive')

인증 및 승인이 필요하므로 지시에 따라 입력


(이하 생략)
성공하면 Mounted로 표시

ls 명령을 실행하면 drive가 표시됩니다

Google Drive에서 CSV 파일 읽기
Colabo와 같은 폴더에 적절한 CSV 파일 넣기

Colab 측에 CSV가 표시되는지 확인
!ls drive/MyDrive/ML/pytorch-sample-luna

Pandas에서 지정한 경로 가져오기(적절한 경로 변경)
import pandas as pd
df = pd.read_csv('drive/MyDrive/ML/Pytorch-sample-luna/luna_sample_candidates.csv')
df

Google Drive에 CSV 파일 저장하기
첫 번째 행의 데이터가 삭제된 파일을 저장하려고 시도합니다.
df[1:].to_csv('drive/MyDrive/ML/Pytorch-sample-luna/luna_sample_candidates_2.csv')

파일이 안전하게 추가되었는지 확인

파이썬 모듈 읽기
적합한 모듈 준비 (화면의 dsets.py)

import 이후 모듈 오류를 찾을 수 없습니다
import dsets

원인은drive/sys입니다.path에 없어서 발견할 수 없습니다

경로 추가
ROOT_PATH = 'drive/MyDrive/ML/pytorch-sample-luna/'
sys.path.append(ROOT_PATH)

불러올 수 있습니다. (오류는 dsets.py 내용의 교정이기 때문에 파일을 읽는 중)
import dsets

드라이브에 외부 데이터 직접 다운로드
!wget -P 'drive/MyDrive/ML/pytorch-sample-luna/' 'https://zenodo.org/record/3723295/files/annotations.csv?download=1'

기타
필요에 따라 드라이브 스토리지 추가 (개인 계정은 Google One일 수 있음)
https://drive.google.com/settings/storage
Reference
이 문제에 관하여(Google Colabo 설정 및 데이터 읽기), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/t_hori/items/4b1aecf55870ae1080b1텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)