Skip to content

Commit

Permalink
Merge pull request #26 from robalberse/bugfix/PJ-024
Browse files Browse the repository at this point in the history
bugfix/PJ-024: Hopefull fix to pandas FutureWarning.
  • Loading branch information
robalberse committed Oct 9, 2023
2 parents acff4a6 + 486bf66 commit abc9a4d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 0 additions & 4 deletions playlistjockey/mixes.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ def dj_mix(donor_df):
"""Mixing algorithm that sorts a playlist like a DJ: utilizing compatible keys, bpms, and energy features."""
# Establish the recipient df that will be the playlist's new order
recipient_df = pd.DataFrame(columns=donor_df.columns)
recipient_df["select_type"] = ""

# Begin by randomly selecting the first song
song_1_index = selects.random_select_song(donor_df)
Expand Down Expand Up @@ -56,7 +55,6 @@ def party_mix(donor_df):
low level of energy, building to a peak at the halfway point, then gradually lowering the energy back down."""
# Establish two recipient DataFrames
rec_front_half = pd.DataFrame(columns=donor_df.columns)
rec_front_half["select_type"] = ""
rec_back_half = rec_front_half.copy()

# Sort the donor_df by energy and danceability
Expand Down Expand Up @@ -139,7 +137,6 @@ def setlist_mix(donor_df):
Starting with high levels of energy, saving the least energetic song for the midpoint, then building the energy back up for the grand finale."""
# Establish two recipient DataFrames
rec_front_half = pd.DataFrame(columns=donor_df.columns)
rec_front_half["select_type"] = ""
rec_back_half = rec_front_half.copy()

# Sort the donor_df by energy and popularity
Expand Down Expand Up @@ -228,7 +225,6 @@ def genre_mix(donor_df):

# Establish the recipient df that will be the playlist's new order
recipient_df = pd.DataFrame(columns=donor_df.columns)
recipient_df["select_type"] = ""

# Begin by randomly selecting the first song
song_1_index = selects.random_select_song(donor_df)
Expand Down
4 changes: 4 additions & 0 deletions playlistjockey/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ def spotify_key_to_camelot(spotify_key, spotify_mode):

def move_song(donor_df, recipient_df, next_song_index, select_type=None):
"""Helper function that moves a song from the donor_df to the recipient_df, given its index."""
# Establish the select_type column in the donor df
if "select_type" not in donor_df:
donor_df["select_type"] = ""

# Copy the song over to the recipient_df, and drop it from the donor_df
if select_type:
donor_df.at[next_song_index, "select_type"] = select_type
Expand Down

0 comments on commit abc9a4d

Please sign in to comment.