Elektrine lite

← Feed

@pbx@fosstodon.org

2026-10-22 00:08 UTC

Today I wanted a simple way to calculate a percentile in Django — I wanted the threshold for the top X% of all values of an integer field. TLDR (top 1%): count = qs.count() top_percentile = qs.values_list("FIELD", flat=True).order_by("-FIELD")[round(count / 100)] Hattip Stack Overflow: https://stackoverflow.com/a/9503282

Replies (0)

No replies.