In [1]:
using DataFrames
using Gadfly
In [6]:
df = readtable("equipament_list.csv");
In [7]:
showcols(df)
Products with 0 quantity were removed from the list.
In [17]:
eliminated_products = df[df[:Qtd] .== 0, :Product]
print(eliminated_products)
In [20]:
df = df[df[:Qtd] .> 0, :];
In [101]:
size(df)
Out[101]:
In [74]:
set_default_plot_size(800px, 1100px)
levels = Array{AbstractString}(sort(df, cols=[:Qtd])[:Product])
plot(df, x=:Qtd, y=:Product,
Scale.y_discrete(levels=levels), Geom.bar(orientation=:horizontal),
Theme(default_color=colorant"lightgreen"))
Out[74]:
In [44]:
for (i, p) in enumerate(df[df[:Qtd] .== 1, :Product])
println("$i. $p")
end
In [75]:
set_default_plot_size(800px, 300px)
levels = Array{AbstractString}(sort(df, cols=[:Qtd])[:Product])
plot(df[df[:Qtd] .> 1, :], x=:Qtd, y=:Product,
Scale.y_discrete(levels=levels),
Geom.bar(orientation=:horizontal), Theme(default_color=colorant"orange"))
Out[75]:
In [97]:
set_default_plot_size(800px, 1100px)
levels = Array{AbstractString}(sort(df, cols=[:UnitPrice])[:Product])
plot(df,
layer(xintercept=[40], Geom.vline, Theme(default_color=colorant"lightgreen", line_width=3px)),
layer(x=:UnitPrice, y=:Product, Geom.bar(orientation=:horizontal)),
Scale.y_discrete(levels=levels),
Theme(default_color=colorant"red"))
Out[97]:
In [100]:
sum(df[df[:UnitPrice] .> 40, :UnitPrice])
Out[100]:
In [105]:
sort(df, cols=[:UnitPrice], rev=true)[1:10, [:Product, :UnitPrice]]
Out[105]:
In [112]:
top_10_values = sum(sort(df, cols=[:UnitPrice], rev=true)[1:10, :UnitPrice])
total_value = df[:Qtd]' * df[:UnitPrice]
print("Top 10: $top_10_values ($(round(top_10_values/total_value[1]*100, 2))%)")