Google Cloud Platform, Vertex AI, Machine Learning, Data Science, Hands On Tutorials.
.groupby(['user_id', 'gender', 'country', 'city', 'age'], as_index=False)[['brand', 'department', 'category']] .agg({k: ";".join for k in ['brand', 'department', 'category']}) ) # Create the target df_agg['last_purchase_brand'] = df_agg['brand'].apply(lambda x: x.split(";")[-1]) df_agg['target'] =