Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python Practical 4 : Acceptance rate by date The Problem Statement The goal is to calculate the overall friend acceptance rate by date. To do

Python Practical 4: Acceptance rate by date
The Problem Statement
The goal is to calculate the overall friend acceptance rate by date.
To do this, we need to merge the df_sent and df_accepted dataframes using the user IDs as the merge keys.
Then, we group the merged dataframe by the date, count the number of accepted actions per date, and calculate the acceptance rate.
Finally, we create a new dataframe with the date and acceptance rate, sorted by date.
Given a table of purchases by date, calculate the month-over-month percentage change in revenue.
The output should include the year-month date (YYYY-MM) and percentage change,
rounded to the 2nd decimal point,
and sorted from the beginning of the year to the end of the year.
The percentage change column will be populated from the 2nd month forward and can be calculated as
((this month's revenue - last month's revenue)/ last month's revenue)*100.
HINT 1:
To calculate the overall friend acceptance rate by date, we need to merge two dataframes :
one containing the friend requests that were sent (action = 'sent') and another containing the
friend requests that were accepted (action = 'accepted').
We can then group the merged dataframe by date and count the number of
accepted requests for each date.
HINT 2:
To merge the two dataframes, we can use the pandas merge function.
First, create two new dataframes: one for the sent requests and another
for the accepted requests.
Use the condition fb_friend_requests.action == 'sent' to filter the rows for the sent requests,
and fb_friend_requests.action == 'accepted' to filter the rows for the accepted requests.
Then, merge the two dataframes using the merge function, specifying the columns to
merge on (user_id_sender and user_id_receiver) and the merge type (how='left').

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Carlos Coronel, Steven Morris

14th Edition

978-0357673034

More Books

Students also viewed these Databases questions

Question

4. How does the worker do the job?

Answered: 1 week ago

Question

Define Management or What is Management?

Answered: 1 week ago

Question

What do you understand by MBO?

Answered: 1 week ago

Question

What is meant by planning or define planning?

Answered: 1 week ago

Question

13. You always should try to make a good first impression.

Answered: 1 week ago