手動特徵擷取 I
你想比較不同商店中特定產品的價格。已預先載入的資料集 sales_df 包含這些特徵:storeID、product、quantity 和 revenue。quantity 與 revenue 告訴你某商店賣出某產品的件數,以及總營收。為了分析目的,知道每個產品的平均單價更有意思。
本練習屬於課程
Python 的降維
練習說明
- 由銷售數量與總營收計算產品單價。
- 從資料集中刪除 quantity 與 revenue 這兩個特徵。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Calculate the price from the quantity sold and revenue
sales_df['price'] = ____
# Drop the quantity and revenue features
reduced_df = sales_df.drop(____, axis=1)
print(reduced_df.head())