Issue
I'm new to Jupyter Notebook (generally new to programming). I already tried searching for similar problems but haven't found the solution.
I get this error: FileNotFoundError: [Errno 2] No such file or directory: 'data/folder/filename.csv'
when trying to run
df = pd.read_csv('data/folder/filename.csv')
The file filename.csv is in the same directory as the notebook I'm using.
Other people (co-learners) who used this notebook were able to run this without any error.
My workaround was by removing the "data/folder/" and just running
df = pd.read_csv('filename.csv')
However, there's now a more complicated one that I have to run:
#set keyword
KEYWORD1='rock'
# read and process the playlist data for keyword
df = pd.read_csv('data/folder/'+KEYWORD1+'filename.csv')\
.merge(pd.read_csv('data/folder/'+KEYWORD1+'filename.csv')\
[['track_id','playlist_id','playlist_name']],\
on='track_id',how='left')
I don't know the workaround for this one. Also, the other people who ran this notebook didn't experience any errors I had. We've installed the same requirements and we've been using jupyter notebook for many days and this is the first time I had an error they (the whole other group) didn't have. Any thoughts on how I can resolve this? Thank you!
Solution
The error is most probably due to the directory where the jupyter notebook command is running, but a workaround for your code will be:
#set keyword
KEYWORD1='rock'
# read and process the playlist data for keyword
df = pd.read_csv(KEYWORD1+'filename.csv')\
.merge(pd.read_csv(KEYWORD1+'filename.csv')\
[['track_id','playlist_id','playlist_name']],\
on='track_id',how='left')
Answered By - Divyessh
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.