一次性删除DataFrame中为空的各个列

# 删除DataFrame为空的各个列
imgpath_columns_list = df_imgpath.columns.to_list()
imgpath_drop_columns_list = list()
for tmp_column in imgpath_columns_list:
    if df_imgpath[tmp_column].notna().sum() == 0:
        imgpath_drop_columns_list.append(tmp_column)
print(imgpath_drop_columns_list)
df_imgpath.drop(columns=imgpath_drop_columns_list, inplace=True)

猜你喜欢

转载自blog.csdn.net/weixin_42782150/article/details/127370601