我想将数据帧分为两个数据帧,并且我有一个名为“ product_type”的列名。取决于产品类型,我需要拆分主数据框并根据另一个列名“ id”对其进行排序。 ID应该匹配。
My data frame:
product, id, product_type
car1, FY-2, forecast
car1, FY-3, forecast
car1, FY-1, forecast
car3, FY-3, reference
car2, FY-1, reference
car4, FY-2, reference
Expected Result:
df1:
product, id, product_type
car1, FY-2, forecast
car1, FY-3, forecast
car1, FY-1, forecast
df2:
product, id, product_type
car3, FY-2, reference
car2, FY-3, reference
car4, FY-1, reference
two data frames are sorted based on the id split based on the product_type.