daily pastebin goal
67%
SHARE
TWEET

Untitled

a guest Mar 24th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import pandas as pd
  2.  
  3. DATA_FOLDER = '../readonly/final_project_data/'
  4. transactions = pd.read_csv(os.path.join(DATA_FOLDER, 'sales_train.csv.gz'), )
  5.  
  6. transactions['date'] = pd.to_datetime(transactions['date'])
  7. grouped_sum = transactions[(transactions['date'].dt.year == 2013) & (transactions['date'].dt.month == 9)].groupby('item_id').sum()
  8.  
  9. def calc(df):
  10.     return df['item_price'] * df['item_cnt_day']
  11.  
  12. grouped_sum['total_revenue'] = grouped_sum.apply(calc, axis=1)
  13. max_revenue = grouped_sum.sort_values('total_revenue', ascending=False).iloc[0,4]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top