I have one DataFrame with a column of Time in the format of String. I want to convert this column to UTC time in second (Int). The code is as follows. However, it is quite slow. Could anyone give some advice to improve the speed? Thanks!
function string2UTC(x::String) t = -1 try td = Dates.DateTime(x, "yyyy-mm-dd HH:MM:SS") t = convert(Int, datetime2unix(td) ) catch return Missing end return t end @time df_ais[:t] = string2UTC.( df_ais[:vmim_timestamp] )
The table has only 3,233,003 rows. The operation takes 207.216866 seconds (556.08 M allocations: 22.040 GiB, 4.91% gc time). The similar operation using Pandas + Python seems much faster.