I am learning machine learning and I came across this code.
I am trying to run the file "Recommender-Systems.py"
from the above source. But it throws an error
ValueError: labels ['timestamp'] not contained in axis.
How can it be removed?
Here's a dropbox link of u.data
file.
Your data is missing the headers so it's being wrongly inferred by the first row.
You need to change a little bit the Recommender-Systems.py
and manually inform the headers.
The right header is available in the README
file from your data set.
Change your file to something like this:
## Explore the data (line 27)
data = pd.read_table('u.data', header=None) # header=None avoid getting the columns automatically
data.columns = ['userID', 'itemID',
'rating', 'timestamp'] # Manually set the columns.
data = data.drop('timestamp', axis=1) # Continue with regular work.
...
## Load user information (line 75)
users_info = pd.read_table('u.user', sep='|', header=None)
users_info.columns = ['useID', 'age', 'gender',
'occupation' 'zipcode']
users_info = users_info.set_index('userID')
...
## Load movie information (line 88)
movies_info = pd.read_table('u.item', sep='|', header=None)
movies_info.columns = ['movieID', 'movie title', 'release date',
'video release date', 'IMDb URL', 'unknown',
'Action', 'Adventure', 'Animation', "Children's",
'Comedy', 'Crime', 'Documentary', 'Drama',
'Fantasy', 'Film-Noir', 'Horror', 'Musical',
'Mystery', 'Romance', 'Sci-Fi',' Thriller',
'War', 'Western']
movies_info = movies_info.set_index('movieID')#.drop(low_count_movies)
This should work (but I'm not sure if I got all the right names for the columns).