(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]
    
    # timezone
    cnt = log_.groupby(['user_id', 'product_id', 'timezone']).size()
    cnt.name = 'useritem_buy_timezone_cnt'
    cnt = cnt.reset_index()
    
    chance = log_.drop_duplicates('order_id').groupby(['user_id', 'timezone']).size()
    chance.name = 'total'
    chance = chance.reset_index()
    
    df = pd.merge(cnt, chance, on=['user_id', 'timezone'], how='left')
    df['useritem_buy_timezone_ratio2'] = df.useritem_buy_timezone_cnt / df.total
    
    col = ['user_id', 'product_id', 'timezone', 'useritem_buy_timezone_ratio2']
    
    df[col].to_pickle('../feature/{}/f308_user-product-timezone.p'.format(folder))
    
    # dow
    cnt = log_.groupby(['user_id', 'product_id', 'order_dow']).size()
    cnt.name = 'useritem_buy_dow_cnt'
    cnt = cnt.reset_index()
    
    chance = log_.drop_duplicates('order_id').groupby(['user_id', 'order_dow']).size()
    chance.name = 'total'
    chance = chance.reset_index()
    
    df = pd.merge(cnt, chance, on=['user_id', 'order_dow'], how='left')
    df['useritem_buy_dow_ratio2'] = df.useritem_buy_dow_cnt / df.total
    
    col = ['user_id', 'product_id', 'order_dow', 'useritem_buy_dow_ratio2']
    
    df[col].to_pickle('../feature/{}/f308_user-product-dow.p'.format(folder))
def make ( T ) : if T == - 1 : folder = 'test' else : folder = 'trainT-' + str ( T ) log_ = log [ log . order_number_rev > T ] # timezone cnt = log_ . groupby ( [ 'user_id' , 'product_id' , 'timezone' ] ) . size ( ) cnt . name = 'useritem_buy_timezone_cnt' cnt = cnt . reset_index ( ) chance = log_ . drop_duplicates ( 'order_id' ) . groupby ( [ 'user_id' , 'timezone' ] ) . size ( ) chance . name = 'total' chance = chance . reset_index ( ) df = pd . merge ( cnt , chance , on = [ 'user_id' , 'timezone' ] , how = 'left' ) df [ 'useritem_buy_timezone_ratio2' ] = df . useritem_buy_timezone_cnt / df . total col = [ 'user_id' , 'product_id' , 'timezone' , 'useritem_buy_timezone_ratio2' ] df [ col ] . to_pickle ( '../feature/{}/f308_user-product-timezone.p' . format ( folder ) ) # dow cnt = log_ . groupby ( [ 'user_id' , 'product_id' , 'order_dow' ] ) . size ( ) cnt . name = 'useritem_buy_dow_cnt' cnt = cnt . reset_index ( ) chance = log_ . drop_duplicates ( 'order_id' ) . groupby ( [ 'user_id' , 'order_dow' ] ) . size ( ) chance . name = 'total' chance = chance . reset_index ( ) df = pd . merge ( cnt , chance , on = [ 'user_id' , 'order_dow' ] , how = 'left' ) df [ 'useritem_buy_dow_ratio2' ] = df . useritem_buy_dow_cnt / df . total col = [ 'user_id' , 'product_id' , 'order_dow' , 'useritem_buy_dow_ratio2' ] df [ col ] . to_pickle ( '../feature/{}/f308_user-product-dow.p' . format ( folder ) )