The original query in Python, using the ORM:
top_scorers_q = DBSession.query(
fg.row_number().over(
order_by=expr.desc(func.sum(PlayerGameStat.score))).label("rank"),
Player.player_id, Player.nick,
func.sum(PlayerGameStat.score).label("total_score"))\