【发布时间】:2021-11-30 19:46:28
【问题描述】:
我正在尝试将当前数据集的格式更改为每行有 1 个用户的格式,并将 Color 和 Food 列中的所有唯一值(值的动态数量)拆分为它们自己的列,其中 Yes 和不,每个用户都有一个唯一的 ID。
Current format:
ID | Name | Color | Food
1 | John | Blue | Pizza
1 | John | Red | Pizza
1 | John | Yellow | Pizza
1 | John | Blue | Ice Cream
1 | John | Red | Ice Cream
1 | John | Yellow | Ice Cream
2 | Kelly | Blue | Pizza
2 | Kelly | Red | Pizza
Desired format:
ID | Name | Color_Blue | Color_Red | Color_Yellow | Food_Pizza | Food_Ice Cream |
1 | John | Yes | Yes | Yes | Yes | Yes |
2 | Kelly | Yes | Yes | No | Yes | No |
【问题讨论】: