Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,10 +17,14 @@ def vote_startup(songs_df):
|
|
| 17 |
except:
|
| 18 |
songs_df = pd.DataFrame(columns=['elo_score', 'artist', 'song_title'])
|
| 19 |
if len(songs_df)>0:
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
if len(songs_df) > 1:
|
| 25 |
# Randomly select a song to compare with
|
| 26 |
sample = songs_df.sample(frac=1)
|
|
@@ -73,10 +77,15 @@ def update_ratings_pos(first_string, second_string, songs_df):
|
|
| 73 |
|
| 74 |
songs_df = songs_df.sort_values(by='elo_score', ascending=False)
|
| 75 |
songs_df.to_csv("songs_df.csv")
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
if len(songs_df) > 1:
|
| 81 |
# Randomly select a song to compare with
|
| 82 |
sample = songs_df.sample(frac=1)
|
|
@@ -111,10 +120,14 @@ def update_ratings_neg(first_string, second_string, songs_df):
|
|
| 111 |
|
| 112 |
songs_df = songs_df.sort_values(by='elo_score', ascending=False)
|
| 113 |
songs_df.to_csv("songs_df.csv")
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
if len(songs_df) > 1:
|
| 119 |
# Randomly select a song to compare with
|
| 120 |
sample = songs_df.sample(frac=1)
|
|
|
|
| 17 |
except:
|
| 18 |
songs_df = pd.DataFrame(columns=['elo_score', 'artist', 'song_title'])
|
| 19 |
if len(songs_df)>0:
|
| 20 |
+
if len(songs_df>10):
|
| 21 |
+
slice_size = 4
|
| 22 |
+
slice = int(len(songs_df)/slice_size)
|
| 23 |
+
sample = songs_df[slice:(slice_size-1)*slice].sample(frac=1).iloc[0]
|
| 24 |
+
song_title, artist = sample["song_title"], sample["artist"]
|
| 25 |
+
else:
|
| 26 |
+
sample = songs_df.sample(frac=1).iloc[0]
|
| 27 |
+
song_title, artist = sample["song_title"], sample["artist"]
|
| 28 |
if len(songs_df) > 1:
|
| 29 |
# Randomly select a song to compare with
|
| 30 |
sample = songs_df.sample(frac=1)
|
|
|
|
| 77 |
|
| 78 |
songs_df = songs_df.sort_values(by='elo_score', ascending=False)
|
| 79 |
songs_df.to_csv("songs_df.csv")
|
| 80 |
+
|
| 81 |
+
if len(songs_df>10):
|
| 82 |
+
slice_size = 4
|
| 83 |
+
slice = int(len(songs_df)/slice_size)
|
| 84 |
+
sample = songs_df[slice:(slice_size-1)*slice].sample(frac=1).iloc[0]
|
| 85 |
+
song_title, artist = sample["song_title"], sample["artist"]
|
| 86 |
+
else:
|
| 87 |
+
sample = songs_df.sample(frac=1).iloc[0]
|
| 88 |
+
song_title, artist = sample["song_title"], sample["artist"]
|
| 89 |
if len(songs_df) > 1:
|
| 90 |
# Randomly select a song to compare with
|
| 91 |
sample = songs_df.sample(frac=1)
|
|
|
|
| 120 |
|
| 121 |
songs_df = songs_df.sort_values(by='elo_score', ascending=False)
|
| 122 |
songs_df.to_csv("songs_df.csv")
|
| 123 |
+
if len(songs_df>10):
|
| 124 |
+
slice_size = 4
|
| 125 |
+
slice = int(len(songs_df)/slice_size)
|
| 126 |
+
sample = songs_df[slice:(slice_size-1)*slice].sample(frac=1).iloc[0]
|
| 127 |
+
song_title, artist = sample["song_title"], sample["artist"]
|
| 128 |
+
else:
|
| 129 |
+
sample = songs_df.sample(frac=1).iloc[0]
|
| 130 |
+
song_title, artist = sample["song_title"], sample["artist"]
|
| 131 |
if len(songs_df) > 1:
|
| 132 |
# Randomly select a song to compare with
|
| 133 |
sample = songs_df.sample(frac=1)
|