Asuming you use the MovieLens 100k data set (obtained from https://grouplens.org/datasets/movielens/).
It comes with a file called 'u.genre' which contains movie information including one hot encoded genres.
Load the data:
import pandas as pd
dt_dir_name = '/path/to/ml-100k/'
genres = ['unknown', 'Action' ,'Adventure' ,'Animation',
'Children' ,'Comedy' ,'Crime' ,'Documentary' ,'Drama' ,'Fantasy',
'Film-Noir' ,'Horror' ,'Musical' ,'Mystery' ,'Romance' ,'Sci-Fi',
'Thriller' ,'War' ,'Western']
movie_data = pd.read_csv(dt_dir_name +'/'+ 'u.item', delimiter='|', names=['movie id' ,'movie title' ,'release date' ,'video release date' ,
'IMDb URL'] + genres)
print('movie data', movie_data.shape)
Then we search for the movies with more than one genre and save the title in a list:
movies_with_several_genres = []
for _, movie in movie_data.iterrows():
if movie[genres].sum() > 1:
movies_with_several_genres.append(movie['movie title'])
print(movies_with_several_genres
Or more pythonic:
print([movie['movie title'] for _, movie in movie_data.iterrows() if movie[genres].sum() > 1])