update amtrak

This commit is contained in:
Kyle Belanger 2024-08-10 08:54:23 -04:00
parent 48f7069257
commit 226551920a

View file

@ -4,6 +4,7 @@ using Cascadia
using DataFrames using DataFrames
using DataFramesMeta using DataFramesMeta
using Dates using Dates
using Statistics
url = "https://juckins.net/amtrak_status/archive/html/history.php?train_num=97&station=&date_start=07%2F01%2F2024&date_end=07%2F31%2F2024&df1=1&df2=1&df3=1&df4=1&df5=1&df6=1&df7=1&sort=schDp&sort_dir=DESC&co=gt&limit_mins=&dfon=1" url = "https://juckins.net/amtrak_status/archive/html/history.php?train_num=97&station=&date_start=07%2F01%2F2024&date_end=07%2F31%2F2024&df1=1&df2=1&df3=1&df4=1&df5=1&df6=1&df7=1&sort=schDp&sort_dir=DESC&co=gt&limit_mins=&dfon=1"
@ -31,11 +32,19 @@ end
mod_df = @chain df begin mod_df = @chain df begin
@rsubset :act_dp != "" @rsubset :act_dp != "" && :s_disrupt != "SD"
@select Not(:comments, :s_disrupt, :cancellations)
@rtransform _ begin @rtransform _ begin
:act_dp = Time(:act_dp, dateformat"HH:MMp") :act_dp = Time(:act_dp, dateformat"HH:MMp")
:orgin_date = Date(replace(:orgin_date, r" \(.*\)" => ""), dateformat"mm/dd/YYYY") :orgin_date = Date(replace(:orgin_date, r" \(.*\)" => ""), dateformat"mm/dd/YYYY")
:sch_dp = DateTime(replace(:sch_dp, r" \(.*\)" => ""), dateformat"mm/dd/YYYY HH:MM p") :sch_dp = DateTime(replace(:sch_dp, r" \(.*\)" => ""), dateformat"mm/dd/YYYY HH:MM p")
end end
# @rtransform :delay = canonicalize(Dates.CompoundPeriod(:act_dp - Time(:sch_dp)))
# @rtransform :delay = canonicalize(:act_dp - Time(:sch_dp))
@rtransform :delay = :act_dp - Time(:sch_dp)
end end
Statistics.mean(mod_df.delay)
mod_df.delay
Statistics.mean(1:20)