获取空日期pandas python的行

Jes*_*ica 5 python pandas

它看起来像这样:

      Dates  N-D  unit
0  1/1/2016  Q1   UD
1            Q2   UD
2            Q3   UD
3  2/1/2016  Q4   UD
4  5/1/2016  Q5   UD
5            Q6   UD
Run Code Online (Sandbox Code Playgroud)

我想过滤掉空的Dates行并将其保存在dataframe blankDate中:

      Dates  N-D  unit
1            Q2   UD
2            Q3   UD
5            Q6   UD


 blankDate=df1[df1['Dates']== '']  #this didn't work 
 df1['Discharge Date'] = pd.to_datetime(df1['Discharge Date']) #then I converted the column to date format but still doesn't work
Run Code Online (Sandbox Code Playgroud)

如果列是一个字符串这段代码工作,它也适用于我认为的数字

blankDate=df1[df1['stringcolumn']== '']
Run Code Online (Sandbox Code Playgroud)

但我如何与空日期行比较?

Vai*_*ali 5

一种方法是用 nan 替换空单元格,然后使用 isnull()

df.Dates = df.Dates.replace('', np.nan)
blankDate = df[df.Dates.isnull()]
Run Code Online (Sandbox Code Playgroud)