Created
March 15, 2020 16:39
-
-
Save ikatsov/c04707548f2903c19a0350d1c66c4b2e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
orders.sort_values(by=['user_id','order_number','add_to_cart_order'], | |
inplace=True) | |
orders_by_uid = orders.groupby("user_id") | |
.apply(lambda order: ' '.join(order['product_id'].tolist())) | |
orders_by_uid = pd.DataFrame(orders_by_uid, | |
columns=['all_orders']) | |
orders_by_uid.reset_index(inplace=True) | |
orders_by_uid.user_id = orders_by_uid.user_id.astype(str) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment