Skip to content

Instantly share code, notes, and snippets.

@aniruddha27
Created March 12, 2020 17:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aniruddha27/81d5357f0e98162b1ad1007ec1e136fa to your computer and use it in GitHub Desktop.
Save aniruddha27/81d5357f0e98162b1ad1007ec1e136fa to your computer and use it in GitHub Desktop.
#new revenue column
df['revenue'] = df.apply(lambda x: x.checkout_price*x.num_orders,axis=1)
#new month column
df['month'] = df['week'].apply(lambda x: x//4)
#list to store month-wise revenue
month=[]
month_order=[]
for i in range(max(df['month'])):
month.append(i)
month_order.append(df[df['month']==i].revenue.sum())
#list to store week-wise revenue
week=[]
week_order=[]
for i in range(max(df['week'])):
week.append(i)
week_order.append(df[df['week']==i].revenue.sum())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment