Xử lý dữ liệu trong Julia
Katerina Zahradova
Instructor
wages thay vì df wages thay vì us_min_wages_data_between_1968_and_2020_with_inflation_adjusted_columnstate_wage_2020 và effective.2020.dollars khó nhớstate, Year, và REGION trong cùng DataFrameĐừng tạo quá nhiều biến mới
wages_no_missing, wages_missing_state_only, wages_original_no_missing, wages_state_mean_no_missing, v.v.Ghi đè! Dùng select!(), transform!(), v.v.
chain để giảm nhu cầu tạo nhiều phiên bản dữ liệu# Nên
replace_missing = 0
replace!(df.col1, missing => replace_missing)
replace!(df.col2, missing => replace_missing)
# Hơn là
replace!(df.col1, missing => 0)
replace!(df.col2, missing => 0)
# Hàm vẽ nhiều biểu đồ đường có nhãn
function make_line_plot(xs, ys,labels; xlabel="", ylabel="", title="")
p = plot(title = title, xlabel = xlabel, ylabel = ylabel)
for (x, y, label) in zip(xs, ys, labels)
plot!(x, y, label=label)
end
p
end
# Chuẩn hóa tên
rename!(df, :ColumnOne => :col_1)
# Hàng thiếu company
df[ismissing.(df.company),:]
# Pivot theo year và state
unstack(wages, :year, :state, :eff_min_wage)
# Thay wages thiếu bằng mức tối thiểu
# Trường hợp xấu nhất
min = minimum(skipmissing(df.wages))
replace!(df.wages, missing => min)
# Join với countries
# Để nghiên cứu tác động của quốc gia đến chất lượng
leftjoin(company, countries, on=:location)



Xử lý dữ liệu trong Julia