final_score_mean

Posted 兔子的尾巴_Mini

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了final_score_mean相关的知识,希望对你有一定的参考价值。

#Author:Mini
#!/usr/bin/env python
import numpy as n
import pymysql
import pandas as pd
conn = pymysql.connect(host="127.0.0.1", user="root", passwd="wangmianny111", db="galaxy_macau_ad",charset=‘utf8‘)
sql1="select * from tripadvisor_chinese"
data=pd.read_sql(sql1,conn)
print("#######################")
print(len(data))
print("***************************")
print(data.columns)

print(data)
print(data.describe())
topic=[‘bubble_rating‘,‘service‘, ‘emplyees‘, ‘Grand_Resort_Deck‘, ‘room‘, ‘Galaxy_macau‘,‘facilities‘, ‘location‘, ‘restaurants_food‘, ‘price‘, ‘hotels‘,‘casino‘, ‘lobby‘, ‘shuttle_bus‘, ‘check_in‘, ‘shopping_center‘,‘check_out‘, ‘demond_show‘]
data=data.T
print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
print(data)

for i in data.columns:
m = 0
sum = 0

for j in range(4,21):
if(data[i].isnull())[j]:
pass
else:
m+=1
sum+=data[i][j]
#print(data[i][0],data[i][j])
#print(sum)

if m==0:
pass
else:
final_score=sum/m
final_score=float(‘%.1f‘ % final_score)
print(sum,m)
print(data[i][0],final_score,data[i][4])
sql = "UPDATE tripadvisor_chinese SET final_score = ‘" + str(final_score) + "‘ WHERE customer_num = ‘" + str(
data[i][0]) + "‘ ;"
conn.query(sql)
conn.commit()
print("sucess!")


#print(data["service"])
"""for i in data.columns:
for j in data:
avg=n.mean(data[i][j])
print("avg:"+avg)
m=+1
"""

以上是关于final_score_mean的主要内容,如果未能解决你的问题,请参考以下文章

VSCode自定义代码片段——CSS选择器

谷歌浏览器调试jsp 引入代码片段,如何调试代码片段中的js

片段和活动之间的核心区别是啥?哪些代码可以写成片段?

VSCode自定义代码片段——.vue文件的模板

VSCode自定义代码片段6——CSS选择器

VSCode自定义代码片段——声明函数