import pymysql from pandas import DataFrame import pandas as pd import matplotlib.pylab as pyl 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(data.describe()) #data1=data.T #print (data1) data.sort_values(by = [‘date‘],axis = 0,ascending = True) #data_2011=data drop_list_2017=[] drop_list_2016=[] drop_list_2015=[] drop_list_2014=[] drop_list_2013=[] drop_list_2012=[] drop_list_2011=[] data_2017=data.copy() data_2016=data.copy() data_2015=data.copy() data_2014=data.copy() data_2013=data.copy() data_2012=data.copy() data_2011=data.copy() #print(data_2017) for i in range(193,len(data)): drop_list_2017.append(i) data_2017=data_2017.drop(drop_list_2017) print("len_2017:"+str(len(data_2017))) #print(data_2017) for i in range(0,193): drop_list_2016.append(i) for i in range(283,len(data)): drop_list_2016.append(i) data_2016=data_2016.drop(drop_list_2016) for i in range(0,283): drop_list_2015.append(i) for i in range(364,len(data)): drop_list_2015.append(i) data_2015=data_2015.drop(drop_list_2015) for i in range(0,364): drop_list_2014.append(i) for i in range(378,len(data)): drop_list_2014.append(i) data_2014=data_2014.drop(drop_list_2014) for i in range(0,378): drop_list_2013.append(i) for i in range(416,len(data)): drop_list_2013.append(i) data_2013=data_2013.drop(drop_list_2013) for i in range(0,416): drop_list_2012.append(i) for i in range(428,len(data)): drop_list_2012.append(i) data_2012=data_2012.drop(drop_list_2012) for i in range(0,428): drop_list_2011.append(i) data_2011=data_2011.drop(drop_list_2011) print("len_2016:"+str(len(data_2016))) print("len_2015:"+str(len(data_2015))) print("len_2014:"+str(len(data_2014))) print("len_2013:"+str(len(data_2013))) print("len_2012:"+str(len(data_2012))) print("len_2011:"+str(len(data_2011))) #print(data_2017) data_2017_describe=data_2017.describe() print(data_2017_describe) data_2016_describe=data_2016.describe() print(data_2016_describe) data_2015_describe=data_2015.describe() print(data_2015_describe) data_2014_describe=data_2014.describe() print(data_2014_describe) data_2013_describe=data_2013.describe() print(data_2013_describe) data_2012_describe=data_2012.describe() print(data_2012_describe) data_2011_describe=data_2011.describe() print(data_2011_describe) timeline=data["date"] comment_score=data["final_score"] pyl.plot(timeline,comment_score,‘o‘) pyl.show() #分布 #comment_score_max=data1