在我的谷歌驱动器中,我有一个名为的文件夹Colab Notebooks/data/,如何将此路径附加到系统,这样我就不必提供数据文件的全名?
我的尝试:
from google.colab import drive
drive.mount('/content/drive')
dat_dir = 'drive/My Drive/Colab Notebooks/data/'
# read data
import pandas as pd
pd.read_csv(dat_dir + 'titanic_kaggle_train.csv') # this works
我要这个
pd.read_csv('titanic_kaggle_train.csv') # Here, I dont have full path
我试过
import sys
sys.path.append(dat_dir) # did not work
# another attempt (did not work)
!export PYTHONPATH=$HOME/drive/My\ Drive/Colab\ Notebooks/data/:$PYTHONPATH
问题
这个命令如何工作?
pd.read_csv('titanic_kaggle_train.csv')
明月笑刀无情
杨__羊羊
相关分类