開始使用免費開始

資料篩選

就像你在影片課程中看到的,你可能會因為各種原因需要篩選資料。

在這個練習中,你會使用篩選來選出 DataFrame 的特定部分:

  • 依照每週各天所記錄的筆數
  • 依照每週各天顧客支付給餐廳的平均金額

本練習屬於課程

使用 pandas 撰寫高效程式碼

檢視課程

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Filter the days where the count of total_bill is greater than $40
total_bill_40 = restaurant_data.groupby('day').____(lambda x: ____[____].____() > 40)

# Print the number of tables where total_bill is greater than $40
print('Number of tables where total_bill is greater than $40:', total_bill_40.shape[0])
編輯並執行程式碼