panads version is 0.20.2
df=pd.DataFrame({'0':['x',np.nan,np.nan],'col':range(3)})
0 col
0 x 0
1 NaN 1
2 NaN 2
df.set_index('0',inplace=True)
df
col
0
x 0
NaN 1
NaN 2
#df.drop(df.index[[0]]) #this can drop reminded by TomAugspurger
df.drop(df.index[[1]]) #this cannot
col
0
x 0
NaN 1
NaN 2
df.drop(df.index[[0,1]]) #drop all
Empty DataFrame
Columns: [col]
Index: []
and if replace NaN(which is np.nan ) in the df with float('nan') , it will get other weirder results
could you please tell me what leads to the problem above? Thx
Comment From: TomAugspurger
Your first one seems OK to me on master, could you try upgrading your version of pandas?
In [10]: df=pd.DataFrame({'0':['x',np.nan,np.nan],'col':range(3)}).set_index('0')
In [11]: df.drop(df.index[0])
Out[11]:
col
0
NaN 1
NaN 2
For your second issue, this probably comes from NaN != NaN
. I'd recommend not putting NaNs in the index.
and when mix float('nan') with np.nan , will get other weirder results
What do you mean?
Comment From: TomAugspurger
Let us know if you have any other questions.