Deleting DataFrame row in Pandas based on column value

前端 未结 10 2232
悲哀的现实
悲哀的现实 2020-11-22 04:08

I have the following DataFrame:

             daysago  line_race rating        rw    wrating
 line_date                                                 
 2007         


        
10条回答
  •  粉色の甜心
    2020-11-22 04:46

    Just adding another way for DataFrame expanded over all columns:

    for column in df.columns:
       df = df[df[column]!=0]
    

    Example:

    def z_score(data,count):
       threshold=3
       for column in data.columns:
           mean = np.mean(data[column])
           std = np.std(data[column])
           for i in data[column]:
               zscore = (i-mean)/std
               if(np.abs(zscore)>threshold):
                   count=count+1
                   data = data[data[column]!=i]
       return data,count
    

提交回复
热议问题