I have a data-frame df
comprising of an identifier column and 4 columns of dates. Please see below for the head of the data-frame.
Identifier A \
0 12253 1989-11-09 00:00:00
1 11413 1990-09-03 00:00:00
2 12337 1977-09-07 00:00:00
3 10610 1994-08-24 00:00:00
4 7493 1993-08-22 00:00:00
B C \
0 2012-03-01 00:00:00 2015-04-01 00:00:00
1 2009-08-16 00:00:00 2015-05-18 00:00:00
2 1977-09-07 00:00:00 1977-09-07 00:00:00
3 2009-01-09 00:00:00 2015-03-01 00:00:00
4 2002-06-03 00:00:00 2015-02-16 00:00:00
D \
0 2012-01-03 00:00:00
1 2015-05-18 00:00:00
2 1977-09-07 00:00:00
3 2015-03-01 00:00:00
4 2015-02-16 00:00:00
I am trying to compare the date columns against each other and where if A>=B>=C>=D then in a new column check True should be returned else False.
So the resulting data-frame would look like:
Identifier A \
0 12253 1989-11-09 00:00:00
1 11413 1990-09-03 00:00:00
2 12337 1977-09-07 00:00:00
3 10610 1994-08-24 00:00:00
4 7493 1993-08-22 00:00:00
B C \
0 2012-03-01 00:00:00 2015-04-01 00:00:00
1 2009-08-16 00:00:00 2015-05-18 00:00:00
2 1977-09-07 00:00:00 1977-09-07 00:00:00
3 2009-01-09 00:00:00 2015-03-01 00:00:00
4 2002-06-03 00:00:00 2015-02-16 00:00:00
D Check\
0 2012-01-03 00:00:00 False
1 2015-05-18 00:00:00 True
2 1977-09-07 00:00:00 True
3 2015-03-01 00:00:00 True
4 2015-02-16 00:00:00 True
I have tried
df['Check'] = np.where(df['A'] >= df['B']>= df['C']>= df['D'], 'True', 'False')
But can't get this to work. What can I try next?