简体   繁体   中英

how can I find the file to read?

import pandas as pd
data = pd.read_csv("/Users/dibaa/train.csv")
y = data['label']
data.drop('label',axis=1,inplace = True)
X = data
y = pd.Categorical(y)

FileNotFoundError: [Errno 2] No such file or directory: '/Users/dibaa/train.csv'

By default pandas will look for the file from the directory you ran the script from. If the csv file is in the same directory then pd.read_csv('train.csv') should work. If not, you'll have to include the absolute path to it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM