1

i have a dataframe with Time colume wiht String31 format. how can i convert this foramt into datetime.

Image

i use Datetime method but it raised an error::

str_1=data_raw.Time[1,:]
DateTime(str_1, "yyyymmdd HHMMSS")

Error:

MethodError: no method matching Int64(::Vector{String31})
Closest candidates are:
(::Type{T})(!Matched::AbstractChar) where T<:Union{Int32, Int64}
@ Base char.jl:51
(::Type{T})(!Matched::AbstractChar) where T<:Union{AbstractChar, Number}
@ Base char.jl:50
(::Type{T})(!Matched::BigInt) where T<:Union{Int128, Int16, Int32, Int64, Int8}
@ Base gmp.jl:36

1 Answers1

2

Do:

DateTime.(str_1, "yyyy-mm-dd HH:MM:SS")

(note the . before ( - it broadcasts DateTime over all elements of str_1)

Bogumił Kamiński
  • 66,844
  • 3
  • 80
  • 107