Put pandas group into separate variable to remove warning.

This commit is contained in:
alwayscompiling
2022-12-01 22:42:43 -05:00
parent 2ec7296c0f
commit 58e616ea47
2 changed files with 8 additions and 6 deletions
+1
View File
@@ -136,3 +136,4 @@ highscores_config.json
deleted_backups/
highscores_data/
TODO.txt
sql_tester.py
+7 -6
View File
@@ -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: