I am looking for an efficient method to `pivot` or `groupby` a data frame where the output is the list of unique items in that subgroup. I am not interested in using loops and would prefer to retain the result as a data frame. Thank you in advance.

**Example df:**

| number | letter | fruit |
| --- | --- | --- |
| 101 | a | apple |
| 101 | b | melon |
| 101 | a | peach |
| 201 | b | grape |
| 101 | b | orange |
| 101 | a | pear |
| 201 | b | apple |
| 201 | a | peach |

**My Code:**

```
df=pd.DataFrame({'number':['101','101','101','201','101','101','201','201'], 'letter': ['a','b','a','b','b','a','b','a'], 'fruit':['apple','melon','peach','grape','orange','pear','apple','peach'] })

pd.pivot_table(df, index='number', columns='letter', values='fruit', aggfunc='sum')

```

**Output:**

| letter | a | b |
| --- | --- | --- |
| **number** |  |  |
| 101 | appleapplepear | melonorange |
| 201 | peach | grapeapple |

---

**Desired Output:**

| letter | a | b |
| --- | --- | --- |
| **number** |  |  |
| 101 | [apple ,pear] | [melon ,orange] |
| 201 | [peach] | [grape ,apple] |