Try:
lst = [0, 1, 'NaN']
mask = df.isin(lst).all(axis=0)
df.drop(mask.loc[mask].index, axis=1, inplace=True)
it will essentially ensure you drop all columns, for which all values are in lst
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.