我在 julia 中打開了一個資料框,其中有 3 列,如下所示:
day month year
1 1 2011
2 4 2015
3 12 2018
我怎樣才能創建一個名為 date 的新列:
day month year date
1 1 2011 1/1/2011
2 4 2015 2/4/2015
3 12 2018 3/12/2018
我正在嘗試這樣做:
df[!,:date]= df.day.*"/".*df.month.*"/".*df.year
但它沒有用。
在 R 我會這樣做:
df$date=paste(df$day, df$month, df$year, sep="/")
有什么類似的嗎?
提前致謝!
uj5u.com熱心網友回復:
JuliaDate在其標準庫中有一個內置型別:
julia> using Dates
julia> df[!, :date] = Date.(df.year, df.month, df.day)
3-element Vector{Date}:
2011-01-01
2015-04-02
2018-12-03
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/398850.html
