本文整理汇总了Python中Main.compute_summary方法的典型用法代码示例。如果您正苦于以下问题:Python Main.compute_summary方法的具体用法?Python Main.compute_summary怎么用?Python Main.compute_summary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Main
的用法示例。
在下文中一共展示了Main.compute_summary方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sf
# 需要导入模块: import Main [as 别名]
# 或者: from Main import compute_summary [as 别名]
def sf(self):
self.console.append("*********************")
self.console.append("---------------------")
self.console.append("$$$$$$$ 开始执行 $$$$$$$")
self.console.append("---------------------")
self.console.append("*********************")
# ---------- 生成网格
if not self.isReadHelp:
QtWidgets.QMessageBox.information(self.label, "文件未读取", "请先读取Help.csv")
tmpButton = self.help_button()
if tmpButton < 0:
return tmpButton
aa = self.read_para()
Main.generateGrid(gloV.lngKm, gloV.latKm, (gloV.LAT_MIN + gloV.LAT_MAX) / 2)
if aa < 0:
return aa
# ---------- 宠物店 宠物医院 抽取
readSaveCommunity = Community.run()
if readSaveCommunity == 'NO_SAVE.':
tmpButton = self.community_button()
if tmpButton < 0:
return tmpButton
if readSaveCommunity == 'NO_DATA.':
self.console.append("*********** 没有本城市 社区 数据点 **********")
return -1
readSaveShopHospital = ShopHospital.run()
if readSaveShopHospital == 'NO_SAVE.':
tmpButton = self.help_button()
if tmpButton < 0:
return tmpButton
if readSaveShopHospital == 'NO_DATA.':
self.console.append("*********** 没有本城市 ShopHospital 数据点 **********")
return -1
# ---------------------------------------------Compute--------------------------------------------------
# ---------- 数据缺失率统计 与 基本统计量
gloV.communitySummary = Main.compute_summary('<社区>', gloV.communityVariableNameStr,
gloV.communityVariableName, len(gloV.communityData), gloV.communityValid, gloV.communityDataType, "w+")
gloV.shopSummary = Main.compute_summary('<宠物店>', gloV.shopVariableNameStr,
gloV.shopVariableName, len(gloV.shopData), gloV.shopValid, gloV.shopDataType, "a")
gloV.hospitalSummary = Main.compute_summary('<宠物医院>', gloV.hospitalVariableNameStr,
gloV.hospitalVariableName, len(gloV.hospitalData), gloV.hospitalValid, gloV.hospitalDataType, "a")
self.print_summary('<社区>', gloV.communityVariableName, gloV.communitySummary)
self.print_summary('<宠物店>', gloV.shopVariableName, gloV.shopSummary)
self.print_summary('<宠物医院>', gloV.hospitalVariableName, gloV.hospitalSummary)
# ---------- 基于Grid的计算: 得到gridCommunity, gridDemand, gridCompete, gridValue
Main.computeGrid()
# -------------------------------------------Write----------------------------------------------------
shopHospitalOutput = Main.merge_output(gloV.shopOutput, 'Shop', gloV.hospitalOutput, '医院')
allOutput = Main.merge_output(gloV.communityOutput, '社区', shopHospitalOutput, 'Shop或医院')
filePointName = "Output-Point.csv"
filePoint = open(filePointName, 'w+', encoding='gb2312')
print('\n开始输出散点图数据:')
for i in allOutput:
for j in i:
try:
filePoint.writelines(j)
except Exception:
print('Point输出编码失败:--- ' + str(j))
filePoint.writelines(',')
filePoint.writelines('\n')
filePoint.close()
self.console.append("----------<Output-Point.csv> 输出完毕!")
print('\n<Output-Point.csv> 输出完毕!')
fileGridName = "Output-Grid.csv"
Main.writeGrid(fileGridName)
self.console.append("----------<Output-Grid.csv> 输出完毕!")
self.console.append("---------- 程序完成! ----------")
# DemoDia.accept()
self.helpButton.setEnabled(False)
self.computeButton.setEnabled(False)
return 0
示例2: run
# 需要导入模块: import Main [as 别名]
# 或者: from Main import compute_summary [as 别名]
#.........这里部分代码省略.........
gloV.communityValid
gloV.communityIsVilla
gloV.communityIsBefore2000
gloV.communityGridId
gloV.communitySummary
修改了:
gloV.communityOutput
"""
# -------------------- Get communityDataAll --------------------
# 运行 readDiskData() 之后拥有的变量:
# gloV.communityVariableNameStr
# gloV.communityVariableName
# gloV.communityVariableNamePosition
# gloV.communityOutput
# gloV.communityDataAll
noSave = readDiskData()
if noSave == 'NO_SAVE.':
return noSave
gloV.communityData = []
gloV.communityGridId = []
gloV.communityValid = {}
gloV.communityIsVilla = []
gloV.communityIsBefore2000 = []
for i in gloV.communityVariableName:
gloV.communityValid[i] = []
gloV.communityOutput[0].append('是否别墅')
gloV.communityOutput[0].append('是否早于2000年竣工')
gloV.communityOutput[0].append('Type')
gloV.communityOutput[0].append('GridId')
gloV.communityOutput[0].append('GenerateTime')
for i in gloV.communityDataAll:
if Main.is_valid(i[0]) and Main.is_valid(i[1]):
if Main.is_right_city(i[0], i[1], gloV.communityVariableName, i, gloV.communityVariableNamePosition):
tmpDataStr = []
# 处理 gloV.communityData
tmpData = []
for j in range(0, len(i)):
tmpData.append(i[j])
tmpDataStr.append(str(i[j]))
if j == 2:
if Main.is_valid(i[j]) and Main.get_income(i[j]) != 0:
gloV.communityValid["区县"].append(Main.get_income(i[j]))
elif Main.is_valid(i[j]):
gloV.communityValid[gloV.communityVariableName[j]].append(i[j])
gloV.communityData.append(tmpData)
# 处理 gloV.communityGridId
lngId = int((i[0] - gloV.LNG_MIN) / gloV.lngLeap)
latId = int((i[1] - gloV.LAT_MIN) / gloV.latLeap)
gloV.communityGridId.append(gloV.gridId[latId][lngId])
# 处理 gloV.communityIsVilla
villaVariableList = ['小区类型', '小区特点', '建筑类别', '建筑结构']
villa = False
for k in villaVariableList:
if k in gloV.communityVariableName and '别墅' in i[gloV.communityVariableNamePosition[k]]:
villa = True
break
if villa:
gloV.communityIsVilla.append(1)
tmpDataStr.append('是')
else:
gloV.communityIsVilla.append(0)
tmpDataStr.append('否')
# 处理 gloV.communityIsBefore2000
if '竣工时间' in gloV.communityVariableName:
tmpDate = i[gloV.communityVariableNamePosition['竣工时间']]
if Main.is_valid(tmpDate) and tmpDate.year < 2000:
gloV.communityIsBefore2000.append(1)
tmpDataStr.append('是')
else:
gloV.communityIsBefore2000.append(0)
tmpDataStr.append('否')
else:
gloV.communityIsBefore2000.append(0)
tmpDataStr.append('否')
# 处理 gloV.communityOutput
tmpDataStr.append('社区')
tmpDataStr.append(str(gloV.gridId[latId][lngId]))
tmpDataStr.append(gloV.generateTime)
gloV.communityOutput.append(tmpDataStr)
if len(gloV.communityData) == 0:
return 'NO_DATA.'
# ---------- 社区数据归一化, 计算"综合评分"
gloV.communitySummary = Main.compute_summary('<社区>', gloV.communityVariableNameStr, gloV.communityVariableName,
len(gloV.communityData), gloV.communityValid, gloV.communityDataType, "no-write")
computeCommunity()
return 0