Skip to content

Instantly share code, notes, and snippets.

@patricoferris
Last active August 4, 2018 12:22
Show Gist options
  • Save patricoferris/528ee5b50185873e1183ee7c20ccb83b to your computer and use it in GitHub Desktop.
Save patricoferris/528ee5b50185873e1183ee7c20ccb83b to your computer and use it in GitHub Desktop.
genres = {}
genre_lookup = {}
scores = {}
cursor.execute('select distinct genre from genres')
for row in cursor:
genre_lookup[len(genre_lookup)] = row[0]
genres[row[0]] = []
for i in range(11):
scores[i] = []
#We start adding the different artists into our dictionaries
for artist in artist_dict:
for genre in artist_dict[artist].genres:
#We don't want to add them more than once - although maybe this could be a weighting
#as in how 'rocky' are the band?
if artist not in genres[genre]:
genres[genre].append(artist_lookup[artist])
mean_score = np.mean(artist_dict[artist].scores)
scores[round(mean_score)].append(artist_lookup[artist])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment