dataframe splict

Posted 兔子的尾巴_Mini

tags:

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

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

 

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

Python:用于元组的 Pandas DataFrame

如何为具有不同颜色的每一行绘制某个 DataFrame 的切片?

数据框架到RDD这段代码无法工作。

C# 中 将IP字符串转换为整型

String与StringBuilder 区别

生成 Tibble / DataFrame 代码