Regarding the Pandas DataFrame 'test_df':
 id_customer   id_order   product_name
    3             78        product1
    3             79        product2
    3             80        product3
    7             100       product4
    9             109       product5
After a groupby on 'id_customer' how is it possible to get:
 id_customer order_1     order_2   product_name_1   product_name_2
    3          78           79           product1         product2
    7          100                       product4      
    9          109                       product5
The goal is to retrieve the minimum between 2 and the number of line matching each 'id_customer' after the groupby, and then, if possible, fill all the above fields.
I started with
def order_to_col(my_dataframe_df,my_list):
  for num in range(0,min(len(my_list),2)):
    my_dataframe_df['order_'+str(num)] = my_list[num]
test_df = test_df.groupby('id_customer').apply(lambda x: order_to_col(test_df,list(x.id_order)))
but I'm quit sure it's not the good approach
 
    