I have the following DataFrame:
title | number |
---|---|
abc | 3 |
edf | 4 |
abc | 2 |
edf | 1 |
How can I produce this output?
The data is grouped by title
column.
title | number |
---|---|
abc | [3, 2] |
edf | [4, 1] |
To create the same dataframe I use you can use the code below:
import pandas as pd
data = {
"title": ['abc', 'edf', 'abc', 'edf'],
"number": [3, 4, 2, 1],
}
df = pd.DataFrame(data=data)