lynn-twinkl commited on
Commit ·
9168705
1
Parent(s): 12d8c7d
Added qcut labeling
Browse files
functions/necessity_index.py
CHANGED
|
@@ -101,3 +101,9 @@ def index_scaler(values):
|
|
| 101 |
x_min = np.min(values)
|
| 102 |
x_max = np.max(values)
|
| 103 |
return [(x - x_min) / (x_max - x_min) if x_max != x_min else 0.5 for x in values]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
x_min = np.min(values)
|
| 102 |
x_max = np.max(values)
|
| 103 |
return [(x - x_min) / (x_max - x_min) if x_max != x_min else 0.5 for x in values]
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
## -------- CATEGORIZE FUNCTION -------
|
| 107 |
+
|
| 108 |
+
def qcut_labels(series, bins=(0,.25,.75,.95,1), labels=('low','medium','high','priority')):
|
| 109 |
+
return pd.qcut(series, q=bins, labels=labels)
|