fatiharaci / spotweety

spotweety.club - a twitter analyzer for spotify
http://spotweety.club/
0 stars 0 forks source link

Which one to choose from songs which have equal number count #14

Closed fatiharaci closed 7 years ago

fatiharaci commented 7 years ago

Using sorted function results like following. This happens because some of the songs have the equal number of occurance in the list

Lust for Life (with The Weeknd) - Lana Del Rey Lust for Life (with The Weeknd) - Lana Del Rey Lust for Life (with The Weeknd) - Lana Del Rey Lust for Life (with The Weeknd) - Lana Del Rey Lust for Life (with The Weeknd) - Lana Del Rey Lust for Life (with The Weeknd) - Lana Del Rey Lust for Life (with The Weeknd) - Lana Del Rey En la memoria - la piel - Rosana En la memoria - la piel - Rosana En la memoria - la piel - Rosana En la memoria - la piel - Rosana En la memoria - la piel - Rosana En la memoria - la piel - Rosana En la memoria - la piel - Rosana En la memoria - la piel - Rosana En la memoria - la piel - Rosana En la memoria - la piel - Rosana En la memoria - la piel - Rosana En la memoria - la piel - Rosana Tek Başına - Erkin Koray Kal Bugün - Can Bonomo Kal Bugün - Can Bonomo Tek Başına - Erkin Koray Tek Başına - Erkin Koray Kal Bugün - Can Bonomo Kal Bugün - Can Bonomo Tek Başına - Erkin Koray Tek Başına - Erkin Koray Ring Na Na - Lali Ring Na Na - Lali

fatiharaci commented 7 years ago

Using stacking mechanisim like following solved the issue. This for iter through the list and check if we have it in top_songs_array if not it adds it to the list up to top_songs_count given. Right now 20 seems to be optimum number for this count.

index_array=[] top_songs_array =[]

for i in range(0, tnum): if (top_songs_count > len(top_songs_array)): top_song = parsed_tweets2[sorted_tweets[i]]['text'] if top_song not in top_songs_array: top_songs_array.append(parsed_tweets2[sorted_tweets[i]]['text']) index_array.append(sorted_tweets[i])