I have a dataframe like this:
NUMBER NAME
1 000231 John Stockton
2 009456 Karl Malone
3 100000901 John Stockton
4 100008496 Karl Malone
I want to obtain a new dataframe with:
NAME VALUE1 VALUE2
1 John Stockton 000231 100000901
2 Karl Malone 009456 100008496
I think I should use pd.groupby()
, but I have no function to pass as an aggregator (I don't need to compute any mean()
, min()
, or max()
value). If I just use pd.groupby()
without any aggregator, I get:
In[1]: pd.DataFrame(df.groupby(['NAME']))
Out[1]:
0 1
0 John Stockton NAME NUMBER 000231 100000901
1 Karl Malone NAME NUMBER 009456 100008496
What am I doing wrong? Do I need to pivot the dataframe?