A few ways to do this:
1.Merge Sname columns in the ratings data frame, at "user_id"
ratings_with_names = ratings.merge(names, on='user_id')
This gives you something like:
user_id movie_id rating unix_timestamp Sname
0 6 86 3 883603013 ANSEL
1 6 14 5 883599249 ANSEL
2 6 98 5 883600680 ANSEL
3 6 463 4 883601713 ANSEL
So, now it's easy to select the rows you need, logical indexing
ratings_with_names[ratings_with_names.Sname == 'ALLAN']
2. Insert user_id that matches the condition in the second data frame, and use it to filter on the first data frame:
ratings[ratings.user_id.isin(names.ix[names.Sname == 'ALLAN', 'user_id'])]
source
share