From 58e616ea476d099b74079467b6acf5fedff63cea Mon Sep 17 00:00:00 2001 From: alwayscompiling Date: Thu, 1 Dec 2022 22:42:43 -0500 Subject: [PATCH] Put pandas group into separate variable to remove warning. --- .gitignore | 1 + utilities/utils.py | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 158f77e..33fdfc9 100644 --- a/.gitignore +++ b/.gitignore @@ -136,3 +136,4 @@ highscores_config.json deleted_backups/ highscores_data/ TODO.txt +sql_tester.py diff --git a/utilities/utils.py b/utilities/utils.py index 5029655..5eeae46 100644 --- a/utilities/utils.py +++ b/utilities/utils.py @@ -219,23 +219,24 @@ def format_highscore_message(group: CategoryGroup) -> str: group = groups.get_group(category.CategoryId) # process data. Want each group sorted correctly and only top X results - group.sort_values("Score", ascending=category.IsAscending, inplace=True) - group = group.head(category.Size).reset_index() + processed_group = ( + group.sort_values("Score", ascending=category.IsAscending).head(category.Size).reset_index() + ) # add each score to list for ind in range(max_cat_size): # need to subtract to deal with category name string - if ind in group.index: - username = group["UserName"][ind].ljust(guild.UsernameLength, " ") + if ind in processed_group.index: + username = processed_group["UserName"][ind].ljust(guild.UsernameLength, " ") # get score, pad to correct length if category.IsTimeRecord: # MM:SS.ms is 7 characters long # if there are single digit minutes, add a space for formatting. - score = get_time_str(group["Score"][ind]) + score = get_time_str(processed_group["Score"][ind]) if score.find(":") and len(score.split(":", maxsplit=1)[0]) < 2: score = " " + score else: - score = str(int(group["Score"][ind])).rjust(7, " ") + score = str(int(processed_group["Score"][ind])).rjust(7, " ") str_list[ind + 1] += f"{ind + 1}: {username} - {score}".ljust(pad_length, " ") else: