Question: 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')..
The following is the data from Acceptance Rate -Data.txt file for this python problem statement.
user_id_sender user_id_receiver date action
ad4943sdz 948ksx123d 2020-01-04 sent
ad4943sdz 948ksx123d 2020-01-06 accepted
dfdfxf94839djjjd92832020-01-04 sent
dfdfxf94839djjjd92832020-01-15 accepted
ffdfff4234234 lpjzjdi49492020-01-06 sent
fffkfld9499993lsldidif 2020-01-06 sent
fffkfld9499993lsldidif 2020-01-10 accepted
fg503kdsdd ofp049dkd 2020-01-04 sent
fg503kdsdd ofp049dkd 2020-01-10 accepted
hh643dfert 847jfkf2032020-01-04 sent
r4gfgf2344234ddr45452020-01-06 sent
r4gfgf2344234ddr45452020-01-11 accepted

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!