如果我有这个数据框:
d = {'col1': [1, np.nan, np.nan], 'col2': [1, np.nan, 1]}
df = pd.DataFrame(data=d)
col1 col2
0 1.0 1.0
1 NaN NaN
2 NaN 1.0
并且只想删除空行以生成以下内容:
d = {'col1': [1, np.nan], 'col2': [1, 1]}
df = pd.DataFrame(data=d)
col1 col2
0 1.0 1
1 NaN 1
最好的方法是什么?
查看文档页面
df.dropna(how='all')