def create_hash_district_map_dict():
file = "cluster_map.csv"
district_hash_map_path = os.path.join(DATA_DIR, CONCRETE_DIR, CLUSTER_MAP_SHEET_DIR, file)
hash_data = pd.read_csv(district_hash_map_path)
## convert the dataframe into dict
hash_map_rule = dict(zip(hash_data.district_hash, hash_data.district_map))
# print(type(hash_map_rule))
saved_file = "cluster_map.pickle"
map_save_file = os.path.join(DATA_DIR, CONCRETE_DIR, CLUSTER_MAP_SHEET_DIR, saved_file)
## save into same dir as file
with open(map_save_file, "wb") as f:
pickle.dump(hash_map_rule, f)
#print(hash_map_rule)
# map the district features in the input data_frame into value
评论列表
文章目录