开始使用免费开始使用

手动特征提取 I

您想在不同商店之间比较某些产品的价格。预加载的数据集 sales_df 包含以下特征:storeIDproductquantityrevenuequantityrevenue 分别表示某个产品在某家商店的销量和总收入。为了分析更有意义,您更关心每件产品的平均价格。

本练习是课程的一部分

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())
编辑并运行代码