[问题] dropna问题

楼主: opu456 (....)   2017-12-05 16:12:21
例如有一个DataFrame
'name' 'age' 'weight'
0 A 12 50
1 B NaN 70
2 C 30 60
3 D 45 NaN
用dropna()会变成
'name' 'age' 'weight'
0 A 12 50
2 C 30 60
如果我想要只有'age' NaN 才删除那列
'name' 'age' 'weight'
0 A 12 50
2 C 30 60
3 D 45 NaN
变成这样
要怎么做呢
谢谢大家
作者: youngman77 (大咩)   2017-12-05 20:31:00
df.dropna(subset=['column_name'])
作者: Czero (悠闲)   2017-12-05 22:10:00
df[~df['age'].isnull()]
楼主: opu456 (....)   2017-12-07 18:31:00
谢谢两位

Links booklink

Contact Us: admin [ a t ] ucptt.com