12345678910111213141516171819202122 |
- # An algorithm for assigning a dataset to pre-existing clusters
- import pandas as p
-
- # Pre-existing aggregated clusters
- clusfile = '../data/9-clusters.agg.pkl'
-
- # A new dataset
- ndsfile = '../data/2016-17-sample.pkl'
-
-
- clusdf = p.read_pickle(clusfile)
- clusdf = clusdf.pivot(index = 'read_time', columns = 'cluster', values = 'kwh_tot_mean')
- del clusdf.columns.name
- print(clusdf.info())
-
-
-
- newdf = p.read_pickle(ndsfile).pivot(index = 'read_time',
- columns = 'icp_id',
- values = 'kwh_tot').loc[clusdf.index, :]
- print(newdf)
- print(newdf.info())
|