Put pandas group into separate variable to remove warning.
This commit is contained in:
@@ -136,3 +136,4 @@ highscores_config.json
|
|||||||
deleted_backups/
|
deleted_backups/
|
||||||
highscores_data/
|
highscores_data/
|
||||||
TODO.txt
|
TODO.txt
|
||||||
|
sql_tester.py
|
||||||
|
|||||||
+7
-6
@@ -219,23 +219,24 @@ def format_highscore_message(group: CategoryGroup) -> str:
|
|||||||
group = groups.get_group(category.CategoryId)
|
group = groups.get_group(category.CategoryId)
|
||||||
|
|
||||||
# process data. Want each group sorted correctly and only top X results
|
# process data. Want each group sorted correctly and only top X results
|
||||||
group.sort_values("Score", ascending=category.IsAscending, inplace=True)
|
processed_group = (
|
||||||
group = group.head(category.Size).reset_index()
|
group.sort_values("Score", ascending=category.IsAscending).head(category.Size).reset_index()
|
||||||
|
)
|
||||||
|
|
||||||
# add each score to list
|
# add each score to list
|
||||||
for ind in range(max_cat_size): # need to subtract to deal with category name string
|
for ind in range(max_cat_size): # need to subtract to deal with category name string
|
||||||
if ind in group.index:
|
if ind in processed_group.index:
|
||||||
username = group["UserName"][ind].ljust(guild.UsernameLength, " ")
|
username = processed_group["UserName"][ind].ljust(guild.UsernameLength, " ")
|
||||||
|
|
||||||
# get score, pad to correct length
|
# get score, pad to correct length
|
||||||
if category.IsTimeRecord:
|
if category.IsTimeRecord:
|
||||||
# MM:SS.ms is 7 characters long
|
# MM:SS.ms is 7 characters long
|
||||||
# if there are single digit minutes, add a space for formatting.
|
# 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:
|
if score.find(":") and len(score.split(":", maxsplit=1)[0]) < 2:
|
||||||
score = " " + score
|
score = " " + score
|
||||||
else:
|
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, " ")
|
str_list[ind + 1] += f"{ind + 1}: {username} - {score}".ljust(pad_length, " ")
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user