text_plain_output_1.png
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import sqlite3

conn = sqlite3.connect('../input/database.sqlite')
score_query = '\nSELECT reviewid, score\nFROM reviews\n'
score_df = pd.read_sql_query(score_query, conn)
genre_query = '\nSELECT *\nFROM genres\n'
genre_df = pd.read_sql_query(genre_query, conn)
conn.close()
genre_df.fillna(value='Not specified', inplace=True)
grouped = genre_df.groupby('reviewid')
genre_df = grouped.aggregate(lambda x: set(x))
result = score_df.join(genre_df, on='reviewid')
assert len(score_df) == len(result)
popmean = result['score'].mean()

means_and_counts = result.groupby(result['genre'].apply(tuple))['score'].agg(['count', 'mean'])
assert means_and_counts['count'].sum() == len(result)
means_and_counts = means_and_counts.sort_values('mean', ascending=False)
means_and_counts = means_and_counts[means_and_counts['count'] > 50].reset_index()
print(means_and_counts)