Skip to content

filter by z-score in a single step #257

Answered by jheer
drewda asked this question in Q&A
Discussion options

You must be logged in to vote

Filter expressions can use window and aggregate functions, so try the following:

dt.filter(d => (d.x - op.mean(d.x)) / op.stdev(d.x) <= 3)

Just keep in mind that the mean and stdev values are computed by group, and so will be sensitive to any preceding groupby verb.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@drewda
Comment options

Answer selected by jheer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants