資料完整性如何?
新的資料已合併進 banking DataFrame,包含 inv_amount 欄位中的投資金額如何分配到四個不同的基金 A、B、C、D 的細節。
此外,顧客的年齡與生日分別儲存在 age 與 birth_date 欄位。
你想了解不同年齡層的顧客如何投資。不過,在分析之前,你想先確定資料正確無誤。你會透過跨欄位檢查 inv_amount 與 age,對照各基金中的投資金額,以及顧客的生日來驗證。
pandas 與 datetime 已分別以 pd 與 dt 匯入。
本練習屬於課程
用 Python 進行資料清理
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Store fund columns to sum against
fund_columns = ['fund_A', 'fund_B', 'fund_C', 'fund_D']
# Find rows where fund_columns row sum == inv_amount
inv_equ = banking[____].____(____) == ____
# Store consistent and inconsistent data
consistent_inv = ____[____]
inconsistent_inv = ____[____]
# Store consistent and inconsistent data
print("Number of inconsistent investments: ", inconsistent_inv.shape[0])