我有一个包含3列的数据框。我想基于列StoreCountryName
的值创建多个数据框。数据框dataset
的示例如下所示。
+----------------------+--+------------------+--+------------------+
| ReceiptCode | | ItemCategoryName | | StoreCountryName |
+----------------------+--+------------------+--+------------------+
| 0000P70322000039467 | | Wrapping | | Japan |
| 0000P70322000031468 | | Kitchen | | Germany |
| 0000P70322000031467 | | Food | | Germany |
| 0000P70322000032267 | | Kitchen | | Japan |
| 0000P70322000031467 | | Food | | Denmark |
| 0000P70322000031867 | | Food | | Denmark |
| 0000P70322000051467 | | Interior | | Germany |
| 0000P70322000087468 | | Kitchen | | Switzerland |
| 0000P70322000031469 | | Leisure | | Germany |
| 0000P70322000031439 | | Food | | Switzerland |
+----------------------+--+------------------+--+------------------+
我希望每个StoreCountryName
值的结果是
print(dataset_Denmark)
+----------------------+--+------------------+--+------------------+
| ReceiptCode | | ItemCategoryName | | StoreCountryName |
+----------------------+--+------------------+--+------------------+
| 0000P70322000031467 | | Food | | Denmark |
| 0000P70322000031867 | | Food | | Denmark |
+----------------------+--+------------------+--+------------------+
还可以自动将数据框命名为dataset+'_Country'
,即dataset_Denmark
吗?