This answer is similar to that provided by @tanemaki, but uses a lambda
expression instead of scipy stats
.
df = pd.DataFrame(np.random.randn(100, 3), columns=list('ABC'))
df[df.apply(lambda x: np.abs(x - x.mean()) / x.std() < 3).all(axis=1)]
To filter the DataFrame where only ONE column (e.g. 'B') is within three standard deviations:
df[((df.B - df.B.mean()) / df.B.std()).abs() < 3]
See here for how to apply this z-score on a rolling basis: Rolling Z-score applied to pandas dataframe