<jupyter_start><jupyter_text>DataFrames.jl 介紹 (二): Joins 與 Split-Apply-Combine Strategy Day 018 作業1：The Split-Apply-Combine Strategy同 Day 017，請載入 2020/4/2 COVID-19 Daily Report 資料集，計算每個國家/地區的累計確診人數，並列出所有資料筆數。<jupyter_code>using DataFrames, CSV
df = CSV.read("../data/04-02-2020.csv")<jupyter_output><empty_output><jupyter_text>計算計算每個國家/地區的累計確診人數【提示】可使用 groupby 相關的函式<jupyter_code>describe(df)
# 顯示所有資料
sort(by(df, :Country_Region, :Confirmed => sum), :Confirmed_sum, rev=true)<jupyter_output><empty_output><jupyter_text>作業2：請列出美國各區域或事件 (依 Province_State 欄) 的累積確診、死亡、康復人數。【提示】使用 Split-Apply-Combine Strategy 時，有幾種不同的函式可以使用，請參照 `DataFrames.jl` 官方文件 [https://juliadata.github.io/DataFrames.jl/stable/lib/functions/DataFrames.groupby](https://juliadata.github.io/DataFrames.jl/stable/lib/functions/DataFrames.groupby)<jupyter_code>describe(df)
func_tuple = (:Confirmed => sum, :Recovered => sum, :Deaths => sum)
us_df = filter(row -> row[:Country_Region] == "US", df)
by(us_df, :Province_State, func_tuple)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14922480620155038, 'fraction_numerical': 0.023255813953488372, 'mean_word_length': 8.306306306306306, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 18, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '333767', 'license': 'Apache-2.0', 'n_tokens_mistral': 529, 'n_tokens_neox': 531, 'n_words': 57, 'path': 'homework/julia_018_hw.ipynb', 'repo_name': 'h164654156465/1st-JuliaMarathon', 'size': '1032'}