Error when Convert date from string to a Python datetime

User 4599 | 4/13/2016, 7:09:17 AM

I learn it from where given a way to Convert InvoiceDate from string to a Python datetime I have the same data looks like that: but when I convert the data type, there is a error looks like that:


User 4599 | 4/13/2016, 7:25:17 AM

if my data is "2015-08" convert is right but how can i convert "201508" to "2015-08" or i can use other ways to convert str "201508" into datetime

User 4599 | 4/13/2016, 7:53:26 AM

I find it in

User 1592 | 4/13/2016, 8:05:59 AM

Hi Wyn As you can see, there is a month but no day in month nor time. You could do something like:

data['X1'] = data['X1'].apply(lambda x: x + "01 00:00:00") data['X1'] = data['X1'].apply(unixtimestamptodatetime)

Namely you add 1st of the month at midnight for each date string.