Try python-dateutil - I found it to be one of the better python modules
for dealing with dates. You may have to replace or strip some of the
string.
Johnf
On 7/19/19 7:44 PM, C W wrote:
Hello all,
I have a date time string that looks like the following.
0 2015-07-01 00:01:44.538420-08:00
1 2015-07-01 00:27:58.717530-08:00
2 2017-07-01 07:07:48.391376-08:00
I have tried the following two different methods, both did not work.
Method one: pandas
import pandas as pd
stamp = pd.to_datetime(my_string, format='%Y%m%d %H:%M:%S')
Method two: datetime package
from datetime import datetime
datetime.strptime(my_string, '%Y-%m-%d %H:%M:%S')
Are both ways suppose to work? Also, does it matter if there are decimals
after seconds? Thanks a lot!
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor