我有一个包含事务的数据帧。我想把数据分组
buy_date category subcategory product actual_price sell_price
1/1/2021 Cloth women shirt style A 5 4
1/1/2021 Cloth men skirt style A 7 6.5
1/1/2021 Accessories ear sky wing 2 1
2/1/2021 Automotive wheel small 21 18
2/1/2021 Automotive wheel big 34 30
1/14/2021 Accessories ring queen couple 3 3
1/17/2021 Cloth women shirt style B 7 7
1/17/2021 Cloth men skirt style A 7 6.5
4/2/2021 Cloth men skirt style A 10 9
5/2/2021 Accessories ring queen couple 3 2.5
7/2/2021 Cloth women shirt style B 16 12
7/2/2021 Automotive wheel big 40 35
2/26/2021 Accessories ring queen couple 4 4
2/26/2021 Cloth women shirt style B 9 5
2/26/2021 Cloth men skirt style A 7 9
2/28/2021 Accessories ear sky wing 2 1
1/3/2021 Automotive wheel big 38 35
1/3/2021 Accessories ring queen couple 4 4
7/3/2021 Automotive wheel big 39 37
3/31/2021 Accessories ring queen couple 4 4
我想得到每个类别和子类别的平均月销售量和实际价格。我尝试过很多方法,但都没有正常工作。 谢谢
只要做:
您可以找到带有三个所需列的
month
然后groupby
试试这个:
将^{} 与聚合
mean
一起使用:相关问题 更多 >
编程相关推荐