Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def task_2(orders, reviews):
- df = orders.merge(reviews, on = 'order_id')
- df['order_delivered_carrier_date'] = pd.to_datetime(df['order_delivered_carrier_date']).dt.date
- df['order_delivered_carrier_date'].dropna(inplace = True)
- df.drop_duplicates()
- grouped_df = df.groupby(['order_delivered_carrier_date', 'order_status']).agg({'order_id':'count'}).reset_index()
- grouped_df.rename(columns = {'order_id': 'order_count', 'order_delivered_carrier_date': 'date'}, inplace = True)
- fig = px.histogram(grouped_df, x= "date", y = "order_count", color="order_status", histfunc="avg")
- fig.update_layout(
- xaxis_rangeslider_visible=True
- )
- fig.show()
- my_reviews = copy.deepcopy(reviews)
- my_reviews['review_answer_timestamp'] = pd.to_datetime(my_reviews['review_answer_timestamp']).dt.date
- grouped_reviews = my_reviews.groupby(['review_answer_timestamp']).agg({'review_score':'mean'}).reset_index()
- grouped_reviews.rename(columns = {'review_answer_timestamp' : 'review_date'}, inplace = True)
- fig2 = px.histogram(grouped_reviews, x= "review_date", y = 'review_score', histfunc = 'avg')
- fig2.update_layout(
- xaxis_rangeslider_visible=True
- )
- fig2.show()
Add Comment
Please, Sign In to add comment