Skip to content

Instantly share code, notes, and snippets.

@kxzk
Created August 9, 2019 21:29
Show Gist options
  • Save kxzk/9a78a0de3de1124ad73d8d62dae6f94a to your computer and use it in GitHub Desktop.
Save kxzk/9a78a0de3de1124ad73d8d62dae6f94a to your computer and use it in GitHub Desktop.
df["unique_products"] = df.groupby("customer_id").agg({"products": "unique"})
# Transform each element -> row - Pandas >= 0.25
df["unique_products"].explode()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment