I'm trying to pivot this dataframe
:
pd.DataFrame([[1, 4], [2, 5], [3, 6]], columns=['a', 'b'])
to this one:
pd.DataFrame([['a', [1, 2, 3]], ['b', [4, 5, 6]]], columns=['key', 'list'])
Ignoring the column renaming, is there a way to do it without iterating over the rows and converting them to a list and then a new column?