将 String31 日期时间格式转换为 Julia 中的日期时间

问题描述 投票:0回答:1

我有一个带有 String31 格式的时间列的数据框。如何将此格式转换为日期时间?

我使用日期时间方法,但它引发了错误::

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

错误:

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
datetime julia datetime-format dataframes.jl
1个回答
2
投票

做:

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

(注意

.
之前的
(
- 它会在
DateTime
的所有元素上广播
str_1

© www.soinside.com 2019 - 2024. All rights reserved.