我有以下python中的主要数据帧
ID Date Product_Name transaction
1 01-01-2018 MS 234
1 01-02-2018 MS 2345
1 02-02-2018 MS 234
2 01-01-2018 HSD 2312
2 02-02-2018 HSD 2234
3 01-01-2018 MS 2123
3 02-02-2018 MS 345
现在,我想基于ID
和Product_Name
对数据帧进行子集,这更具动态性。因此,从上面的数据帧中,它将创建3个动态数据帧(基于ID
和Product_Name
列中的唯一值),并使用以下子集过滤器将其命名为MS_1
、HSD_2
、MS_3
ID = 1 and Product_Name = 'MS'
ID = 2 and Product_Name = 'HSD'
ID = 3 and Product_Name = 'MS'
有可能在熊猫身上做吗
更好的方法是创建
dictionary of DataFrame
s:以及选择使用:
编辑:
@jpp建议按元组创建密钥:
对于使用所有子数据帧转换回大数据帧,请使用^{} :
相关问题 更多 >
编程相关推荐