Remove NaN/NULL columns in a Pandas dataframe?

后端 未结 3 498
执笔经年
执笔经年 2020-12-13 03:50

I have a dataFrame in pandas and several of the columns have all null values. Is there a built in function which will let me remove those columns?

3条回答
  •  醉梦人生
    2020-12-13 04:06

    Function for removing all null columns from the data frame:

    def Remove_Null_Columns(df):
        dff = pd.DataFrame()
        for cl in fbinst:
            if df[cl].isnull().sum() == len(df[cl]):
                pass
            else:
                dff[cl] = df[cl]
        return dff 
    

    This function will remove all Null columns from the df.

提交回复
热议问题