Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- DATA_FOLDER = '../readonly/final_project_data/'
- transactions = pd.read_csv(os.path.join(DATA_FOLDER, 'sales_train.csv.gz'), )
- transactions['date'] = pd.to_datetime(transactions['date'])
- grouped_sum = transactions[(transactions['date'].dt.year == 2013) & (transactions['date'].dt.month == 9)].groupby('item_id').sum()
- def calc(df):
- return df['item_price'] * df['item_cnt_day']
- grouped_sum['total_revenue'] = grouped_sum.apply(calc, axis=1)
- max_revenue = grouped_sum.sort_values('total_revenue', ascending=False).iloc[0,4]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement