I have two columns, created date & closed date, format as under. I'm required to extract only the date from each column & try to make a difference
0 12/31/2015 11:59:45 PM
1 12/31/2015 11:59:44 PM
2 12/31/2015 11:59:29 PM
3 12/31/2015 11:57:46 PM
4 12/31/2015 11:56:58 PM
I have tried to use str.split
command (using space to segregate) to get only the dates from both created date & closing date
However, if I try to take the difference I'm getting the following error:
unsupported operand type(s) for -: 'str' and 'str'
a = nyc311['Created Date']
nyc311['Created Date Revised'] = a.str.split('[ ]').str.get(0)
b = nyc311['Closed Date']
nyc311['Closed Date Revised'] = b.str.split('[ ]').str.get(0)
nyc311['Request_Closing_Time'] = nyc311['Closed Date Revised'] -nyc311['Created Date Revised']
Created date and closing date came out as expected, however, I need to achieve the time lag from created date to the closing date, which is not possible as mentioned because of the error message. This may be a silly question, I'm new to python. Help would be much appreciated.