返回A列的日期大于B列的记录

时间:2019-06-25 08:00:00

标签: python pandas

我有一个数据框(df),其中包含2个日期列Column_AColumn_B,如下所示:

      Column_A    Column_B
0               07/11/2016
1   01/11/2010  01/07/2016
2   22/04/2014  02/04/2015
3   08/01/2007  01/06/2015
4   15/11/2004  
5   09/10/2000  01/09/2015
6   04/09/2006  25/03/2016
7   21/09/2017  01/07/2016
8   01/08/2005  01/12/2016
9   18/02/2003  12/02/2016
10  15/07/2016  14/12/2015
11  
12  26/11/2013  26/11/2013
13  13/09/2003  16/10/2016
14  03/09/2009  26/03/2015

我想返回Column_A中的日期晚于Column_B中的日期的记录。缺少所有缺少一个或两个日期的记录。我想要的输出将是:

      Column_A    Column_B
0   21/09/2017  01/07/2016
1   15/07/2016  14/12/2015

我尝试过:

IncorrectOrder = df[df[Column_A]>df[Column_B]] 

但是我得到了错误:

TypeError: '>' not supported between instances of 'datetime.datetime' and 'str'

有人可以让我知道我哪里出问题了吗?

谢谢

0 个答案:

没有答案