Skip to content

Instantly share code, notes, and snippets.

@aviatesk
Last active October 9, 2020 12:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aviatesk/68a6734a44a6408a6db380cf8bc1cce2 to your computer and use it in GitHub Desktop.
Save aviatesk/68a6734a44a6408a6db380cf8bc1cce2 to your computer and use it in GitHub Desktop.
plot julia repl usage
using Dates, DataFrames, Pipe, Plots
df = let
ds = DateTime[]
r = r"# time: (?<datetime>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})"
for line in readlines(normpath(homedir(), ".julia/logs/repl_history.jl"))
m = match(r, line)
isnothing(m) || push!(ds, DateTime(m[:datetime], dateformat"Y-m-d H:M:S"))
end
DataFrame(datetime = ds)
end
let
histogram(df.datetime, xticks = nothing)
p1 = xlabel!(string(minimum(ds), " ~ ", maximum(ds)))
p2 = @pipe df |>
transform(_, :datetime => ByRow(dayofweek) => :dow) |>
groupby(_, :dow) |>
combine(_, nrow) |>
sort(_, :dow) |>
plot(_.dow, _.nrow, title = "by day of week")
p3 = @pipe df |>
transform(_, :datetime => ByRow(Hour) => :hour) |>
groupby(_, :hour) |>
combine(_, nrow) |>
sort(_, :hour) |>
plot(_.hour, _.nrow, title = "by hour")
plot(p1, p2, p3, size = (1500,1500), layout = (3, 1))
end
@aviatesk
Copy link
Author

aviatesk commented Oct 9, 2020

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment