Question: For this assignment, use the cc _ info.csv and transactions.csv files. Your submission should include: 1 . The Python script. 2 . Sample output. 3
For this assignment, use the ccinfo.csv and transactions.csv files. Your
submission should include:
The Python script.
Sample output.
An explanation of your approach and reasoning behind your code.
Each question is worth points, broken down as follows:
Python script: points
Output: points
Code explanation and reasoning: points
Question : Suspicious Transaction Analysis points
Company ABC suspects that transactions that exceed a certain threshold within a short period
of time might be fraudulent. Using the transactions DataFrame:
Identify all transactions that are greater than $
Sort these highvalue transactions by the creditcard column and then by date.
For each creditcard, calculate the time difference in days between consecutive
highvalue transactions.
Add a new column called suspicious to indicate whether a transaction is considered
suspicious. A transaction is considered suspicious if:
It occurs within days of the previous highvalue transaction for the same
creditcard.
Print the creditcard, transactiondollaramount, date, suspicious
columns for all highvalue transactions.
Hint: Use pdtodatetime to ensure date format compatibility and diff to calculate
consecutive differences in days.
Question : Outlier Detection in Transaction Amounts points
Outlier detection can help identify unusual spending patterns. Using the transactions
DataFrame:
Calculate the median and interquartile range IQR for the
transactiondollaramount column.
Define transactions as "outliers" if their transactiondollaramount is either below
Q IQR or above Q IQR.
Create a new column named isoutlier in the transactions DataFrame. Set it to
True for outliers and False for nonoutliers.
Calculate and print the percentage of transactions flagged as outliers.
Hint: Use NumPy functions like nppercentile to calculate Qth percentile and Q
th percentile
Question : Daily Transaction Volume Analysis by Location points
Fraud patterns may also emerge from analyzing transaction volumes over time and by location.
Using both ccinfo and transactions DataFrames:
Merge ccinfo and transactions on the creditcard column.
Group the merged DataFrame by date and state, and calculate the total transaction
amount and transaction count for each state on each date.
Identify the top states with the highest total transaction amounts for each date and
print the results.
Additionally, calculate the daily transaction amount average for each state and print the
top states with the highest averages over the entire period.
Hint: Use groupby to aggregate daily transaction data and sort to identify the top states. For this assignment, use the ccinfo.csv and transactions.csv files. Your submission should include:
The Python script.
Sample output.
An explanation of your approach and reasoning behind your code.
Each question is worth points, broken down as follows:
Python script: points
Output: points
Code explanation and reasoning: points
Question : Suspicious Transaction Analysis points
Company ABC suspects that transactions that exceed a certain threshold within a short period of time might be fraudulent. Using the transactions DataFrame:
Identify all transactions that are greater than $
Sort these highvalue transactions by the creditcard column and then by date.
For each creditcard, calculate the time difference in days between consecutive highvalue transactions.
Add a new column called suspicious to indicate whether a transaction is considered suspicious. A transaction is considered suspicious if:
It occurs within days of the previous highvalue transaction for the same creditcard.
Print the creditcard, transactiondollaramount, date, suspicious columns for all highvalue transactions.
Hint: Use pdtodatetime to ensure date format compatibility and diff to calculate consecutive differences in days.
Question : Outlier Detection in Transaction Amounts points
Outlier detection can help identify unusual spending patterns. Using the transactions DataFrame:
Calculate the median and interquartile range IQR for the transactiondollaramount column.
Define transactions as "outliers" if their transactiondollaramount is either below Q IQR or above Q IQR. For this assignment, use the ccinfo.csv and transactions.csv files. Your submission should include:
The Python script.
Sample output.
An explanation of your approach and reasoning behind your code.
Each question is worth points, broken down as follows:
Python script: points
Output: points
Code explanation and reasoning: points
Question : Suspicious Transaction Analysis points
Company ABC suspects that transactions that exceed a certain threshold within a short period of time might be fraudulent. U Create a new column n
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
