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 : 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 dfsent and
dfaccepted 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 monthovermonth percentage change in revenue.
The output should include the yearmonth date YYYYMM and percentage change, rounded to the nd 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 nd month forward and can be calculated as
this month's revenue last month's revenue last month's revenue
HINT : 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 : 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 fbfriendrequests.action 'sent' to filter the rows for the sent requests,
and fbfriendrequests.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 useridsender and
useridreceiver and the merge type how'left'
The following is the data from Acceptance Rate Data.txt file for this python problem statement.
useridsender useridreceiver date action
adsdz ksxd sent
adsdz ksxd accepted
dfdfxfdjjjd sent
dfdfxfdjjjd accepted
ffdfff lpjzjdi sent
fffkfldlsldidif sent
fffkfldlsldidif accepted
fgkdsdd ofpdkd sent
fgkdsdd ofpdkd accepted
hhdfert jfkf sent
rgfgfddr sent
rgfgfddr accepted
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
