从数据框中删除在98%以上的功能部件中具有零的行

时间:2018-06-29 22:47:36

标签: python-3.x dataframe attributeerror

rowzeros = (traindata == 0).sum(axis=1) #Number of zeros in each row  
rowzeros = pd.DataFrame(rowzeros) #Converting to a dataframe 
[row1, column1] = traindata.shape  #We will use the number of rows in the for loop
for i in range(row1):
    if rowzeros.iloc[i, 0] > .98*row1:  #If >98% values in a row are zero
       traindata = traindata.drop(traindata.index[[i]], inplace=True) #drop the row
print(traindata.shape) #Checking the size of the data frame to confirm 

我正在尝试从数据框中删除所有具有超过预定义数量的零的行。
现在我收到此错误,AttributeError:'NoneType'对象没有属性 '形状'。 我看过其他帖子,但有相同的错误,但上下文不同 感谢您的帮助

0 个答案:

没有答案
相关问题