I have a question regarding the Q Python file error.

Asked 2 years ago, Updated 2 years ago, 21 views

I'm reading a book called Data Analysis using Python Library. I tried to run it with PiCham or ipython according to the example that comes out, but there is an error.

Downloaded Movieline 1M from www.grouplens.org/node/73. It's a download file.

import pandas as pd

unames = ['user_id', 'gender', 'age', 'occupation', 'zip']
users = pd.read_table('ml-1m/users.dat', sep='::', header=None, names=unames)

rnames = ['user_id', 'movie_id', 'rating', 'timestamp']
ratings = pd.read_table('ml-1m/ratings.dat', sep='::', header=None, names=rnames)

mnames = ['movie_id', 'title', 'genres']
movies = pd.read_table('ml-1m/movies.dat', sep='::', header=None, names=mnames)

We did the same as in the above example

I'm trying to enter a file code and run it

FileNotFoundError: [Errno 2] No such file or directory: 'ml-1m/users.dat'

There is also an error saying that the file cannot be found. What should I do? In this case, I have the file, but is this happening because the path is wrong?

python

2022-09-22 21:16

1 Answers

If you look at the code, it looks like 'ml-1m/movies.dat'.

There should be a location where you extracted the downloaded file.

For example, if you extracted ml-1m.zip to the C:\Users\MyName\Downloads\ml-1m\ location, the movies.dat file will be located in C:\Users\MyName\Downloads\ml-1movies.dat.

Once this location has been identified, change 'ml-1m/movies.data' to 'C:/Users/MyName/Downloads/ml-1m/movies.dat' in the above code.

If you do not want to modify the code, you can use C:\Users\MyName\Downloads to run the above source.


2022-09-22 21:16

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.