[Tutor] genfromtxt and dtype to convert data to correct format

Alan Gauld alan.gauld at yahoo.co.uk
Thu May 19 12:16:17 EDT 2016


On 19/05/16 12:51, Ek Esawi wrote:
> Thanks again!
> 
> I tried a combination of the suggestions and still not getting what i want.
> 
> Here are the original code, file, and output.
> 
> CODE
> 
> mport csv; import numpy as np; from datetime import datetime, date, time
> 
> CF = lambda date: datetime.strptime(bytes.decode(date),
> '%m/%d/%Y').strftime('%Y-%m-%d')

Again you have strftime at the end so it will result in a string
output. You need to remove that if you want a date/time/datetime
object as a result.

That's assuming that it is a datetime style object that you want.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list