我正在做一个零售数据存储,并试图得到一个类别和子类别的报告。我试着看看答案,但没能找到解决办法。你知道吗
下面是示例数据(不是完整的数据集)
+-----------------+--------------+
| Category | Sub-Category |
+-----------------+--------------+
| Furniture | Bookcases |
| Furniture | Chairs |
| Office Supplies | Labels |
| Furniture | Tables |
| Office Supplies | Storage |
| Furniture | Furnishings |
+-----------------+--------------+
我的代码:
orders[['Category', 'Sub-Category']].groupby(by=['Category', 'Sub-Category']).nunique()
我的结果集:
Category Sub-Category
Category Sub-Category
Furniture Bookcases 1 1
Chairs 1 1
Furnishings 1 1
Tables 1 1
Office Supplies Appliances 1 1
Art 1 1
我只想
Category Sub-Category
Furniture Bookcases
Chairs
Furnishings
Tables
Office Supplies Appliances
Art
有没有办法让我把这些数字藏起来。如果不包含nunique
,则返回的是对象而不是实际输出。你知道吗
我不确定这个功能是否存在于pandas中,或者我应该看看其他的东西。你知道吗
使用
相关问题 更多 >
编程相关推荐