未接來電
你已在前面的練習完成了 churn 資料集的重塑,現在可以開始使用了。你記得有個地方特別引起你的注意,你很確定自己在資料中看到了明顯的模式。
在建立分類模型之前,你決定先做點更簡單的事。你想看看還能從資料中學到什麼。你會透過對層級進行 unstack 來重塑資料,但你也知道這個過程會產生需要處理的遺漏值。
churn DataFrame 包含位於洛杉磯與紐約的顧客各種特徵,已提供給你使用。請先在主控台檢視它!
本練習屬於課程
使用 pandas 重塑資料
練習說明
- 將
churnDataFrame 以churn這個層級進行 unstack,並以 0 填補遺漏值。 - 依
voice_mail_plan欄位遞減、再依international_plan欄位遞增的順序,排序churnDataFrame。 - 列印最終的
churn_sortedDataFrame。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Unstack churn level and fill missing values with zero
churn = ____.____(level=____, ____=____)
# Sort by descending voice mail plan and ascending international plan
churn_sorted = churn.____(____=[____, ____],
____=[____, ____])
# Print final DataFrame and observe pattern
print(____)