Commit 275baf11 authored by François Févotte's avatar François Févotte

Ex 03-3 (suite)

parent 1188bdbe
This diff is collapsed.
This diff is collapsed.
# Affichage des DataFrames dans la sortie HTML
function info(df::DataFrame)
pretty(x) = x
pretty(x::Float64) = @sprintf "%.6f" x
pretty(::Type{Union{T,Missing}}) where {T} = "$T?"
function printrow(i)
print("<tr>")
print("<th>$i</th>")
for j in 1:ncol(df)
print("<td>$(pretty(df[i,j]))</td>")
end
print("</tr>")
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("<tr><td>...</td></tr>")
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("<table>")
print("<thead>")
print("<tr><th></th>")
for col in names(df)
print("<th>$col</th>")
end
print("</tr>")
print("<tr><th></th>")
for col in names(df)
print("<th>$(pretty(eltype(df[!,col])))</th>")
end
print("</tr>")
print("</thead>")
print("<tbody>")
printrows()
print("</tbody>")
print("</table>\n")
end
# Permet de construire des durées avec une syntaxe comme :
# 7Days
const Years = Year(1)
const Days = Day(1)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment