|
@@ -0,0 +1,23 @@
|
|
1
|
+# Aggregrate given clusters
|
|
2
|
+import pandas as p
|
|
3
|
+
|
|
4
|
+def aggregator(widedf, clusdf):
|
|
5
|
+ clusters = clusdf.cluster.unique()
|
|
6
|
+ clusters.sort()
|
|
7
|
+ aggv = {}
|
|
8
|
+ qlow = lambda x: x.quantile(0.250)
|
|
9
|
+ qhigh = lambda x: x.quantile(0.750)
|
|
10
|
+ for c in clusters:
|
|
11
|
+ icps = clusters[clusters.cluster == c].icp_id.values
|
|
12
|
+ subdf = widedf[icps]
|
|
13
|
+ agged = subdf.agg('median', 'mean', qlow, qhigh)
|
|
14
|
+ print(agged)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+def main():
|
|
18
|
+ wd = p.read_pickle()
|
|
19
|
+ cd = p.read_pickle()
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+if __name__ == "__main__":
|
|
23
|
+ main()
|