Using a data-set, I am trying to group the values on the basis of a key(order_id) using the groupby(). However, the return type being groupby object, I am not able to convert into a data frame which is the requirement.
I have tried using groupby to aggregate on the basis of a key. I also tried converting into a list.
import pandas as pd
table=pd.read_csv("chiporders.csv", sep='\t')
df_chiporders= pd.DataFrame(table)
type(df_chiporders)
type(df_chiporders['item_name'])
df_chiporders.item_name
df_grp=df_chiporders.groupby('order_id')['quantity'].apply(list)
print df_grp
Expected result : The result in a data Frame.
please refrain using Count()
, Sum()
because my answer should have the actual values in a dataframe