Drop rows with all zeros in pandas data frame

前端 未结 13 1206
礼貌的吻别
礼貌的吻别 2020-11-27 11:57

I can use pandas dropna() functionality to remove rows with some or all columns set as NA\'s. Is there an equivalent function for drop

13条回答
  •  孤独总比滥情好
    2020-11-27 12:26

    For me this code: df.loc[(df!=0).any(axis=0)] did not work. It returned the exact dataset.

    Instead, I used df.loc[:, (df!=0).any(axis=0)] and dropped all the columns with 0 values in the dataset

    The function .all() droped all the columns in which are any zero values in my dataset.

提交回复
热议问题