(T)
T = 0
    folder = 'trainT-0'
T = 0
    folder = 'trainT-0'
T = 0 folder = trainT - 0
def make(T):
    """
    T = 0
    folder = 'trainT-0'
    """
    if T==-1:
        folder = 'test'
    else:
        folder = 'trainT-'+str(T)
        
    log_ = log[log.order_number_rev>T]
        
    gr = log_.groupby(['user_id', 'product_id'])
    
    user = gr.add_to_cart_order.mean().to_frame()
    user.columns = ['useritem_mean_pos_cart']
    user['useritem_sum_pos_cart'] = gr.add_to_cart_order.sum()
    user['useritem_min_pos_cart'] = gr.add_to_cart_order.min()
    user['useritem_median_pos_cart'] = gr.add_to_cart_order.median()
    user['useritem_max_pos_cart'] = gr.add_to_cart_order.max()
    user['useritem_std_pos_cart'] = gr.add_to_cart_order.std()
    user.reset_index(inplace=True)
    
    user.to_pickle('../feature/{}/f306_user-product.p'.format(folder))
    
    # === near5 ===
    log_ = log[log.order_number_rev>T][log.order_number_rev<=(T+5)]
        
    gr = log_.groupby(['user_id', 'product_id'])
    
    user = gr.add_to_cart_order.mean().to_frame()
    user.columns = ['useritem_mean_pos_cart_n5']
    user['useritem_sum_pos_cart_n5'] = gr.add_to_cart_order.sum()
    user['useritem_min_pos_cart_n5'] = gr.add_to_cart_order.min()
    user['useritem_median_pos_cart_n5'] = gr.add_to_cart_order.median()
    user['useritem_max_pos_cart_n5'] = gr.add_to_cart_order.max()
    user['useritem_std_pos_cart_n5'] = gr.add_to_cart_order.std()
    user.reset_index(inplace=True)
    
    user.to_pickle('../feature/{}/f306_user-product_n5.p'.format(folder))
def make ( T ) : if T == - 1 : folder = 'test' else : folder = 'trainT-' + str ( T ) log_ = log [ log . order_number_rev > T ] gr = log_ . groupby ( [ 'user_id' , 'product_id' ] ) user = gr . add_to_cart_order . mean ( ) . to_frame ( ) user . columns = [ 'useritem_mean_pos_cart' ] user [ 'useritem_sum_pos_cart' ] = gr . add_to_cart_order . sum ( ) user [ 'useritem_min_pos_cart' ] = gr . add_to_cart_order . min ( ) user [ 'useritem_median_pos_cart' ] = gr . add_to_cart_order . median ( ) user [ 'useritem_max_pos_cart' ] = gr . add_to_cart_order . max ( ) user [ 'useritem_std_pos_cart' ] = gr . add_to_cart_order . std ( ) user . reset_index ( inplace = True ) user . to_pickle ( '../feature/{}/f306_user-product.p' . format ( folder ) ) # === near5 === log_ = log [ log . order_number_rev > T ] [ log . order_number_rev <= ( T + 5 ) ] gr = log_ . groupby ( [ 'user_id' , 'product_id' ] ) user = gr . add_to_cart_order . mean ( ) . to_frame ( ) user . columns = [ 'useritem_mean_pos_cart_n5' ] user [ 'useritem_sum_pos_cart_n5' ] = gr . add_to_cart_order . sum ( ) user [ 'useritem_min_pos_cart_n5' ] = gr . add_to_cart_order . min ( ) user [ 'useritem_median_pos_cart_n5' ] = gr . add_to_cart_order . median ( ) user [ 'useritem_max_pos_cart_n5' ] = gr . add_to_cart_order . max ( ) user [ 'useritem_std_pos_cart_n5' ] = gr . add_to_cart_order . std ( ) user . reset_index ( inplace = True ) user . to_pickle ( '../feature/{}/f306_user-product_n5.p' . format ( folder ) )