列表索引超出范围处理CSV文件

时间:2018-12-19 15:44:46

标签: python pandas python-2.7 list

我有一个文件score.csv;它有13320行和3列-列是'timestamp','Score'和'label'。

我想逐块处理数据,每个块由360行组成。如果我有(得分> 0.5,标签== 1),则计数= 1(如果我得到1,则不必操纵所有块),程序将跳到下一个360行块。

我遇到此错误:“列表索引超出范围”

df = pd.DataFrame(dataSet, columns = 
 ['timestamp','Score','label'] )
 L=[]
 x=0
 for y,row in  df.iterrows():
   data=  row.to_dict() 
   Score=data['Score']
   label=data['label']
   L.append((Score,label))

 for i in range (0,len(L),360):
     x=x+1

    for j in range(i,360*x):

       if((L[j][0] >=0.4) and L[j][1]==1):
          TruePostive=TruePostive+1
          print("the TruePostive is in block number" ,x)

       if((L[j][0] < 0.4) and L[j][1]==1):
          TrueNegative=TrueNegative+1
          print("the TrueNegative is in block number" ,x)

       if((L[j][0] >= 0.4) and L[j][1]==0):
          FalsePositive=FalsePositive+1
          print("the FalsePositive is in block number" ,x)

       if((L[j][0] < 0.4) and L[j][1]==0):
          FalseNegative=FalsePositive+1
          print("the FalseNegative is in block number" ,x) 

  print("TruePostive=",TruePostive)
  print("TrueNegative=", TrueNegative)
  print("FalsePositive=", FalsePositive)
  print("FalseNegative=", FalseNegative)

0 个答案:

没有答案