选取非空行

2020-04-20  本文已影响0人  492284513d5a

>>> import pandas as pd         
>>> df = pd.read_csv('test.csv')
>>> print df
       name   id
0  ZhangSan  1.0
1      LiSi  2.0
2    WangEr  NaN
3     WanZi  4.0
>>> print df['id'].notnull()    
0     True
1     True
2    False
3     True
Name: id, dtype: bool
>>> print df[df['id'].notnull()]
===========================================================
#删除重复列
DataFrame.drop_duplicates(self, subset: Union[Hashable, Sequence[Hashable], NoneType] = None, keep: Union[str, bool] = 'first', inplace: bool = False, ignore_index: bool = False) → Union[ForwardRef('DataFrame'), NoneType]
===========================================================



上一篇下一篇

猜你喜欢

热点阅读