Skip to content

Instantly share code, notes, and snippets.

@FBosler
Last active August 18, 2019 08:22
Show Gist options
  • Save FBosler/d89ed6b767899b9217d4d0fc37c25770 to your computer and use it in GitHub Desktop.
Save FBosler/d89ed6b767899b9217d4d0fc37c25770 to your computer and use it in GitHub Desktop.
enriches dummy data
customer_data = pd.DataFrame(df.groupby('customer')['order_date'].min())
customer_data.columns = ['customer_first_order']
customer_data.head(2)
# combine first booking with our dummy data
df = pd.merge(df,customer_data.reset_index(),on='customer')
df.head(2)
#determine if a order is a repeat order or first order
df['type_of_order'] = np.where(df['order_date'] != df['customer_first_order'], 'repeat', 'first')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment