手动特征提取 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())