Answered step by step
Verified Expert Solution
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 : 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'
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started