Thank you all for the replies. The array comprehension works.
On Thursday, May 26, 2016 at 10:49:41 PM UTC+5:30, Alex Mellnik wrote:
>
> To expand slightly on what Milan said, while you can pass DateTime an
> array of strings and a format code, in some cases the conversion function
> you want to use may not accept arrays. In this case, you can do the same
> thing with array comprehension:
>
> df1 = DataFrame(V1 = DateTime[DateTime(d, "m/d/y H:M") for d in ["4/5/2002
> 04:20", "4/5/2002 04:25"]])
>
>
>
> On Thursday, May 26, 2016 at 6:55:42 AM UTC-7, Milan Bouchet-Valat wrote:
>>
>> Le jeudi 26 mai 2016 à 06:15 -0700, akrun a écrit :
>> > I am using the DataFrames package. I find it difficult to convert to
>> > DateTime.
>> >
>> > println(DateTime("4/5/2002 04:20", "m/d/y H:M"))
>> > gives output
>> >
>> > 2002-04-05T04:20:00
>> >
>> > However, if I try
>> >
>> > df1 = DataFrame(V1 = ["4/5/2002 04:20", "4/5/2002 04:25"])
>> > println(DateTime(df1[:V1]))
>> > gives
>> >
>> > ArgumentError: Delimiter mismatch. Couldn't find first
>> > delimiter, "-", in date string
>> > in parse at dates/io.jl:152
>> >
>> >
>> > Is there any workaround?
>> This isn't specific to data frames. You also get this with
>> V1 = ["4/5/2002 04:20", "4/5/2002 04:25"]
>> DateTime(V1)
>>
>> Anyway, you need to pass the format as in your first example:
>> DateTime(V1, "m/d/y H:M")DateTime(df1[:V1], "m/d/y H:M")
>>
>>
>> Regards
>>
>