※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 61.222.64.169
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1547701128.A.F2B.html
※ 編輯: orange0914 (61.222.64.169), 01/17/2019 13:04:02
各位大大好
想請問當一個df.describe()
若資料型態為'object' or 'bool'會顯示出
count
unique
top
freq
如何獲得unique = 1 的column 全部名稱
並進行drop
感謝各位大大
-----------------------------------------------------
底下我用一個很多步驟的方式
不知道有無更簡易的方式
bool_feats = df.select_dtypes(include = ['bool']).columns
for i in bool_feats:
df[i] = df[i].astype('int')
df.columns[df.sum()==0]
這樣可以獲得unique = 1 的columns 再進行drop
-----------------------------------------------------
--