def shopInfo(): res = {} shop_info = helper.loadShopInfo() for shop in shop_info: tmp = [] for i in xrange(2,6): if shop_info[shop][i] == '': tmp.append(0) else: tmp.append(shop_info[shop][i]) res[shop] = tmp return res
def getShopFeatures(gap): airdata = loadAirData() shop_info = helper.loadShopInfo() with open(helper.get_feature_path(gap,'air_feature'),'w') as fout: fout.write("air\n") for shop in xrange(1,2001): shop = str(shop) city = shop_info[shop][0] for date in util.getDate(start = config.LABELSTARTDATE): tmp = airdata[airdata.Date == date][city] fout.write("%d,%s,%s\n"%(tmp,shop,date.strftime("%Y-%m-%d")))
def getShopFeatures(gap): weatherdata = loadWeatherData() shop_info = helper.loadShopInfo() flag = True with open(helper.get_feature_path(gap, 'weather_feature'), 'w') as fout: for shop in xrange(1, 2001): shop = str(shop) city = shop_info[shop][0] for date in util.getDate(start=config.LABELSTARTDATE): feature, msg = getFeature(weatherdata[city][date]) if flag: fout.write("%s\n" % (",".join(msg))) flag = False tmp = ",".join(map(str, feature)) fout.write("%s,%s,%s\n" % (tmp, shop, date.strftime("%Y-%m-%d")))
def shopInfo(): res = {} shop_info = helper.loadShopInfo() lis = [] for i in xrange(5): lis.append(collections.defaultdict(int)) for shop in shop_info: lis[0][ shop_info[shop][0] ] += 1 lis[1][ shop_info[shop][1] ] += 1 lis[2][ shop_info[shop][6] ] += 1 lis[3][ shop_info[shop][7] ] += 1 lis[4][ shop_info[shop][8] ] += 1 lis1 = [] for dic in lis: idx = dict(map(lambda x: (x[1],x[0]),enumerate(map(lambda x: x[0],sorted(dic.items(), key = lambda x: -x[1]))))) lis1.append(idx) return shop_info,lis1
def getCityGroup(): res = dict() shop_info = helper.loadShopInfo() for shop, tmp in shop_info.items(): res[shop] = tmp[1] return res
def getCityCate2Group(): res = dict() shop_info = helper.loadShopInfo() for shop, tmp in shop_info.items(): res[shop] = (tmp[0], tmp[7]) return res
#coding=utf-8 import os import sys import datetime import numpy as np sys.path.append('..') import utils.helper as helper import utils.config as config hangzhou = set([]) shop_info = helper.loadShopInfo() for shop in shop_info: if shop_info[shop][0] == '杭州': hangzhou.add(shop) print len(hangzhou) def loadData(gap, expansion=False): festival = helper.loadFestival() data = [] com = [] week_day = (int(gap) + 1) % 7 with open(helper.get_data_path(gap, 'data')) as fin: for line in fin: tmp = line.strip().split("#") shop, date = tmp[1].split(',') #if date < '2016-09-10' and date > '2016-09-01' and shop in hangzhou: # continue date = datetime.datetime.strptime(date, '%Y-%m-%d') if date in festival: