Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# ジョッキーの複勝率の計算
def cal_jockey(jid, rdt):
query = Result.objects.filter(jockey_id=jid, race__race_dt__lt=rdt).exclude(rank=0)
run_all = query.count()
run_t3 = query.filter(rank__lte=3).count()
ratio = round(run_t3 / run_all, 2) if run_all != 0 else 0
return ratio
df["jockey_t3r"] = df.apply(lambda row: cal_jockey(row["jockey_id"], row["race_dt"]), axis=1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.