MCPcopy
hub / github.com/ranaroussi/quantstats / get_outliers

Function get_outliers

quantstats/stats.py:50–59  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

48
49def distribution(returns, compounded=True, prepare_returns=True):
50 def get_outliers(data):
51 # https://datascience.stackexchange.com/a/57199
52 Q1 = data.quantile(0.25)
53 Q3 = data.quantile(0.75)
54 IQR = Q3 - Q1 # IQR is interquartile range.
55 filtered = (data >= Q1 - 1.5 * IQR) & (data <= Q3 + 1.5 * IQR)
56 return {
57 "values": data.loc[filtered].tolist(),
58 "outliers": data.loc[~filtered].tolist(),
59 }
60
61 if isinstance(returns, _pd.DataFrame):
62 warn(

Callers 1

distributionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected