def get_weather_dict(self,data_dir):
t0 = time()
filename = '../data_raw/' + data_dir.split('/')[-2] + '_weather.csv.dict.pickle'
dumpload = DumpLoad( filename)
if dumpload.isExisiting():
return dumpload.load()
resDict = {}
df = self.load_weatherdf(data_dir)
for index, row in df.iterrows():
resDict[row['time_slotid']] = (index, row['weather'], row['temparature'], row['pm25'])
for name, group in df.groupby('time_date'):
resDict[name] = (-1, mode(group['weather'])[0][0], mode(group['temparature'])[0][0], mode(group['pm25'])[0][0])
dumpload.dump(resDict)
print "dump weather dict:", round(time()-t0, 3), "s"
return resDict
评论列表
文章目录