# Affichage des DataFrames dans la sortie HTML using DataFrames using Printf function info(df::DataFrame) try WEAVE_ARGS catch display(df) return end pretty(x) = x pretty(x::Float64) = @sprintf "%.6f" x pretty(::Type{Union{T,Missing}}) where {T} = "$T?" function printrow(i) print("") print("$i") for j in 1:ncol(df) print("$(pretty(df[i,j]))") end print("") end function printrows() i = 1 while i<=nrow(df) && i<=3 printrow(i) i += 1 end i>nrow(df) && return if i < nrow(df)-2 print("...") end i = max(i, nrow(df)-2) while i<=nrow(df) printrow(i) i += 1 end end println("$(nrow(df)) rows × $(ncol(df)) columns") print("") print("") print("") for col in names(df) print("") end print("") print("") for col in names(df) print("") end print("") print("") print("") printrows() print("") print("
$col
$(pretty(eltype(df[!,col])))
\n") end # Meilleure intégration entre Plotly et Weave function disp() try WEAVE_ARGS catch display(plot!()) return end buf = IOBuffer() show(buf, MIME("text/html"), plot!()) seekstart(buf) str = String(read(buf)) m = match(r"(.*)"s, str) return if m === nothing str else m.captures[1] end |> print end