データのフィルタリング
動画レッスンで見たように、さまざまな理由でデータをフィルタリングする必要があります。
この演習では、フィルタリングを使って 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])