gabrielspmoreira / chameleon_recsys

Source code of CHAMELEON - A Deep Learning Meta-Architecture for News Recommender Systems

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Some more concise code suggestions during data preprocessing

szq261299 opened this issue · comments

def flatten_list_series(series_of_lists):
    return pd.DataFrame(series_of_lists.apply(pd.Series).stack().reset_index(name='item'))['item']

equals

def fun(series_of_lists):
    L =[]
    for i in series_of_lists:
        L.extend(i)
    return L 
dict(articles_original_df[['url','id_encoded']].apply(lambda x: (x['url'], x['id_encoded']), axis=1).values)

equals to

articles_original_df.set_index('url')['id_encode'].to_dict()