add new projects
This commit is contained in:
parent
6b3e184544
commit
cd15995892
3 changed files with 40 additions and 1 deletions
29
LearnJulia/src/amtrak.jl
Normal file
29
LearnJulia/src/amtrak.jl
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
using HTTP
|
||||||
|
using Gumbo
|
||||||
|
using Cascadia
|
||||||
|
|
||||||
|
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"
|
||||||
|
|
||||||
|
resp = HTTP.get(url)
|
||||||
|
|
||||||
|
page = parsehtml(String(resp.body))
|
||||||
|
# println(String(resp.body))
|
||||||
|
sel = Selector("table")
|
||||||
|
s = sel"tr"
|
||||||
|
eachmatch(sel, page.root)
|
||||||
|
rows = eachmatch(s, page.root)
|
||||||
|
|
||||||
|
|
||||||
|
# need to make this a nested for loopS
|
||||||
|
for i in rows
|
||||||
|
text = nodeText(eachmatch(Selector("tr"), i)[1])
|
||||||
|
println("$text")
|
||||||
|
end
|
||||||
|
|
||||||
|
for i in rows
|
||||||
|
e = eachmatch(Selector("tr"), i)
|
||||||
|
for x in e
|
||||||
|
text = nodeText(eachmatch(Selector("td"),x)[1])
|
||||||
|
println("$text")
|
||||||
|
end
|
||||||
|
end
|
|
@ -16,7 +16,7 @@ x = replace(x, " " => "_", "+" => "pos", "(" => "", ")" => "", "%" => "pct")
|
||||||
return x
|
return x
|
||||||
end
|
end
|
||||||
|
|
||||||
#need to convert flu year to categroical
|
#need to convert Month to categroical
|
||||||
|
|
||||||
df = @chain df_raw begin
|
df = @chain df_raw begin
|
||||||
rename(format_names, _)
|
rename(format_names, _)
|
||||||
|
@ -25,6 +25,13 @@ df = @chain df_raw begin
|
||||||
@rtransform :flu_year = ifelse(:month >= 10, :year + 1, :year)
|
@rtransform :flu_year = ifelse(:month >= 10, :year + 1, :year)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
fig = Figure(; size = (600,400))
|
||||||
|
ax = Axis(fig[1,1])
|
||||||
|
lines!(ax, df.month, df.pct_tests_pos_for_influenza; color = df.flu_year)
|
||||||
|
|
||||||
plt = data(df) * mapping(:month, :pct_tests_pos_for_influenza; color = :flu_year) * visual(Lines)
|
plt = data(df) * mapping(:month, :pct_tests_pos_for_influenza; color = :flu_year) * visual(Lines)
|
||||||
|
|
||||||
draw(plt)
|
draw(plt)
|
||||||
|
|
||||||
|
fig
|
|
@ -2,11 +2,14 @@
|
||||||
AlgebraOfGraphics = "cbdf2221-f076-402e-a563-3d30da359d67"
|
AlgebraOfGraphics = "cbdf2221-f076-402e-a563-3d30da359d67"
|
||||||
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
|
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
|
||||||
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
|
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
|
||||||
|
Cascadia = "54eefc05-d75b-58de-a785-1a3403f0919f"
|
||||||
CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"
|
CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"
|
||||||
Chain = "8be319e6-bccf-4806-a6f7-6fae938471bc"
|
Chain = "8be319e6-bccf-4806-a6f7-6fae938471bc"
|
||||||
Cleaner = "caabdcdb-0ab6-47cf-9f62-08858e44f38f"
|
Cleaner = "caabdcdb-0ab6-47cf-9f62-08858e44f38f"
|
||||||
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
|
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
|
||||||
DataFramesMeta = "1313f7d8-7da2-5740-9ea0-a2ca25f37964"
|
DataFramesMeta = "1313f7d8-7da2-5740-9ea0-a2ca25f37964"
|
||||||
|
Gumbo = "708ec375-b3d6-5a57-a7ce-8257bf98657a"
|
||||||
|
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
|
||||||
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
|
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
|
||||||
SQLite = "0aa819cd-b072-5ff4-a722-6bc24af294d9"
|
SQLite = "0aa819cd-b072-5ff4-a722-6bc24af294d9"
|
||||||
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
|
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
|
||||||
|
|
Loading…
Reference in a new issue