using Dates
dateReported = map((x) -> string(x), df[:DateReported])
df[:DateOccurred] = map((x) -> if match(r"^((19|20)\d\d)(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])", x)!=nothing Date(x, DateFormat("yyyymmdd")) end, dateOccurred)
我正在尝试将数据框列的类型从 Int64 更改为 Date。
最后一条语句返回错误
Date not defined
while loading In[18], in expression starting on line 1
in anonymous at In[18]:1
in map at /Users/ajkale/.julia/v0.3/DataArrays/src/datavector.jl:117
我正在 ipython julia 笔记本中尝试这个。不过这在 REPL 中工作得很好。
最佳答案
在 0.3 版本中,日期不属于 Julia 标准库的一部分。从那时起,Julia 0.4 和现在的 0.5 都将其纳入标准库中。
关于julia - Date 在 ipython 笔记本中不起作用,但在 julia REPL 上起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27094669/