Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele Challenge: Compliance Data Dashboard | Analyzing and Visualizing Compliance Data
Practice
Projects
Quizzes & Challenges
Visat
Challenges
/
Python for Compliance Officers
Osio 2. Luku 5
single

single

bookChallenge: Compliance Data Dashboard

Pyyhkäise näyttääksesi valikon

As you approach the challenge of building a compliance data dashboard, recall how pandas enables you to efficiently analyze transaction data and how matplotlib helps you visualize patterns that may be relevant for compliance monitoring. These tools are essential for summarizing large datasets, identifying anomalies, and communicating findings to stakeholders in a compliance context.

123456789101112131415161718192021222324252627282930313233343536
import pandas as pd import matplotlib.pyplot as plt # Hardcoded transaction data data = { "id": [1, 2, 3, 4, 5, 6, 7, 8], "amount": [1200, 500, 3200, 1500, 700, 2200, 4000, 800], "account_id": ["A01", "A02", "A01", "A03", "A02", "A01", "A03", "A02"] } df = pd.DataFrame(data) # Calculate summary statistics total_amount = df["amount"].sum() average_amount = df["amount"].mean() max_amount = df["amount"].max() print("Total transaction amount:", total_amount) print("Average transaction amount:", average_amount) print("Maximum transaction amount:", max_amount) # Aggregate by account for bar chart account_totals = df.groupby("account_id")["amount"].sum() account_totals.plot(kind="bar", title="Total Transaction Amounts per Account") plt.xlabel("Account ID") plt.ylabel("Total Amount") plt.tight_layout() plt.show() # Identify anomalies: transactions > 2 std dev above mean mean_amount = df["amount"].mean() std_amount = df["amount"].std() anomaly_threshold = mean_amount + 2 * std_amount anomalies = df[df["amount"] > anomaly_threshold] print("Transactions above anomaly threshold (2 std dev):") print(anomalies)
copy

To structure your compliance dashboard, follow a clear sequence: start by loading and summarizing your transaction data, using pandas to calculate totals and averages. Next, use matplotlib to visualize aggregated results, such as total transactions per account, to spot trends or concentrations. Finally, apply statistical analysis to flag any transactions that are unusually large—those that are more than two standard deviations above the mean—helping you quickly detect potential compliance risks.

Tehtävä

Swipe to start coding

Build a Python script that acts as a compliance data dashboard. The script must:

  • Calculate the total, average, and maximum transaction amount from the DataFrame.
  • Aggregate transaction amounts by account and prepare the data for a bar chart visualization.
  • Identify all transactions where the amount is more than two standard deviations above the mean.
  • Store all results in variables as referenced in the starter code.

Ratkaisu

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 2. Luku 5
single

single

Kysy tekoälyä

expand

Kysy tekoälyä

ChatGPT

Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme

some-alt