akoumjian / datefinder

Find dates inside text using Python and get back datetime objects
http://datefinder.readthedocs.org/en/latest/
MIT License
635 stars 167 forks source link

Result contains extra dates instead of one #108

Closed imanojkumar closed 1 year ago

imanojkumar commented 5 years ago

I have a column in Pandas 'Comment Text' which contains the dates in this format: 7/09/2018 11:59:37 AM;12:01:33 PM;00:01:56 But when I did something like this:

import datefinder as dtf findDate = dtf.find_dates(df1['Comment Text'][0]) for dates in findDate: print(dates)

I got the following result: 2018-07-09 11:59:37 2019-06-20 12:01:33 2019-06-20 00:01:56

Which is not correct as I was expecting only 2018-07-09 to return as result.

H20Watermelon commented 5 years ago

I suspect it is because you have two times (12:01:30 PM, and 00:01:56) that are not preceded by dates, so the function gives you a default date (which is the date on which you run the function June 20, 2019), for each time.