From 366c7ca827642de18865606df45ae5f45448ac2c Mon Sep 17 00:00:00 2001 From: Jury Razumau Date: Sun, 14 Jul 2024 18:17:03 +0200 Subject: [PATCH] address copy-on-write-related warnings pandas is moving to a copy-on-write model. From their guide: > CoW means that any DataFrame or Series derived from another in any way always behaves as a copy. As a consequence, we can only change the values of an object through modifying the object itself. Thus, `new_teams["trb"].fillna(0, inplace=True)` would not work with CoW (trb would be filled with zeroes only in a copy, not in the original `new_teams` dataframe). This can be addressed by using a slightly different syntax for in-place updates. Migration guide: https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html#copy-on-write-migration-guide --- scripts/teams.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/teams.py b/scripts/teams.py index c48dce8..c5de3fe 100644 --- a/scripts/teams.py +++ b/scripts/teams.py @@ -103,7 +103,7 @@ def add_new_teams(self, tournament: Tournament, player_rating: PlayerRating): new_teams["trb"] = new_teams.baseTeamMembers.map( lambda x: player_rating.calc_rt(x, self.q) ) - new_teams["trb"].fillna(0, inplace=True) + new_teams.fillna({"trb": 0}, inplace=True) new_teams["rating"] = new_teams["trb"] * NEW_TEAMS_LOWERING_COEFFICIENT new_teams["prev_rating"] = None new_teams["prev_place"] = None @@ -111,4 +111,4 @@ def add_new_teams(self, tournament: Tournament, player_rating: PlayerRating): def calc_trb(self, player_rating: PlayerRating): self.data["trb"] = player_rating.calc_tech_rating_all_teams(q=self.q) - self.data["trb"].fillna(0, inplace=True) + self.data.fillna({"trb": 0}, inplace=True)