# ax.set_ylabel('Counts') # ax.set_xlim(-0.25,max(word_number_association)+1.25) # ax.set_xticklabels(words.keys(), rotation=45) # ax.minorticks_on() # plt.show() # ################################################################# over_time = [] for ii in range(len(the_albums.keys())): album = the_albums[the_albums.keys()[ii]] year = int(the_albums[the_albums.keys()[ii]]['year']) artist = album['artist'] if 'lyrics' in album['tracks']: word_count = funcs.word_counts_in_album(album, 'n***a') time = funcs.album_length(album, strout=False) over_time.append((word_count, time, year)) over_time = np.array(over_time) counts_df = DataFrame(over_time, columns=['Count', 'Time', 'Year']) over_time_cumulative = [] over_time_normed = [] years = [] for year in set(counts_df.Year): years.append(year) num_in_year = sum(counts_df.Year == year) over_time_cumulative.append(counts_df[counts_df.Year == year].Count.sum()) over_time_normed.append(counts_df[counts_df.Year == year].Count.sum()/float(num_in_year))
# ax.set_ylabel('Counts') # ax.set_xlim(-0.25,max(word_number_association)+1.25) # ax.set_xticklabels(words.keys(), rotation=45) # ax.minorticks_on() # plt.show() # ################################################################# over_time = [] badwords = ["n***a", "bitch", "f**k", "shit"] for ii in musicinfo.index: album = musicinfo.Album[ii] year = int(musicinfo.Year[ii]) artist = musicinfo.Artist[ii] word_count = funcs.word_counts_in_album(musicinfo.ix[ii], badwords, nigga_fold=True) word_count_list = word_count.values() word_count_list.append(year) over_time.append(word_count_list) over_time = np.array(over_time) colheads = [word[0].upper() + "*" * (len(word) - 1) for word in badwords] colheads.append("Year") counts_df = DataFrame(over_time, columns=colheads) over_time_cumulative = [] over_time_normed = [] years = []