Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele Challenge: Analyze Weekly Sales Data | Data Analysis for Operations Decisions
Python for Operations Managers

bookChallenge: Analyze Weekly Sales Data

As an operations manager, you have learned how to use pandas to organize and analyze your operational data, and matplotlib to visualize key metrics for better decision making. In this challenge, you will apply these skills to a typical scenario: analyzing a week's worth of sales data to extract actionable insights. By leveraging pandas for data aggregation and matplotlib for visualization, you can quickly summarize performance, identify top-selling products, and communicate findings clearly to your team.

12345678910111213141516171819
import pandas as pd # Example DataFrame for a week's sales data = { 'day': ['Mon', 'Mon', 'Tue', 'Tue', 'Wed', 'Wed', 'Thu', 'Thu', 'Fri', 'Fri', 'Sat', 'Sat', 'Sun', 'Sun'], 'item': ['Widget', 'Gadget', 'Widget', 'Gadget', 'Widget', 'Gadget', 'Widget', 'Gadget', 'Widget', 'Gadget', 'Widget', 'Gadget', 'Widget', 'Gadget'], 'units_sold': [10, 5, 12, 8, 7, 6, 15, 9, 14, 7, 13, 8, 11, 6], 'revenue': [100, 75, 120, 120, 70, 90, 150, 135, 140, 105, 130, 120, 110, 90] } df = pd.DataFrame(data) # Example summary calculations total_revenue = df['revenue'].sum() best_selling_item = df.groupby('item')['units_sold'].sum().idxmax() print(f"Weekly Sales Summary") print(f"---------------------") print(f"Total Revenue: ${total_revenue}") print(f"Best-Selling Item: {best_selling_item}")
copy

When working with sales data for operational decisions, it is important to aggregate key metrics such as total revenue and units sold by item. Using pandas, you can easily group and sum data to pinpoint top performers. Visualizations like bar charts created with matplotlib make it easier to spot trends and communicate results to stakeholders. Always ensure your summary reports are clear, concise, and tailored to the needs of your audience.

Tehtävä

Swipe to start coding

Write a Python script to analyze and visualize weekly sales data for operations management decisions.

  • Calculate the total revenue for the week using the revenue column of the DataFrame.
  • Identify the best-selling item based on total units_sold for each item.
  • Plot a bar chart showing total units sold per item using matplotlib.
  • Print a summary report displaying the total revenue and the best-selling item.

Ratkaisu

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

Suggested prompts:

Can you show me how to visualize this sales data using matplotlib?

How can I find the daily sales trends from this data?

Can you help me summarize the units sold for each item?

close

bookChallenge: Analyze Weekly Sales Data

Pyyhkäise näyttääksesi valikon

As an operations manager, you have learned how to use pandas to organize and analyze your operational data, and matplotlib to visualize key metrics for better decision making. In this challenge, you will apply these skills to a typical scenario: analyzing a week's worth of sales data to extract actionable insights. By leveraging pandas for data aggregation and matplotlib for visualization, you can quickly summarize performance, identify top-selling products, and communicate findings clearly to your team.

12345678910111213141516171819
import pandas as pd # Example DataFrame for a week's sales data = { 'day': ['Mon', 'Mon', 'Tue', 'Tue', 'Wed', 'Wed', 'Thu', 'Thu', 'Fri', 'Fri', 'Sat', 'Sat', 'Sun', 'Sun'], 'item': ['Widget', 'Gadget', 'Widget', 'Gadget', 'Widget', 'Gadget', 'Widget', 'Gadget', 'Widget', 'Gadget', 'Widget', 'Gadget', 'Widget', 'Gadget'], 'units_sold': [10, 5, 12, 8, 7, 6, 15, 9, 14, 7, 13, 8, 11, 6], 'revenue': [100, 75, 120, 120, 70, 90, 150, 135, 140, 105, 130, 120, 110, 90] } df = pd.DataFrame(data) # Example summary calculations total_revenue = df['revenue'].sum() best_selling_item = df.groupby('item')['units_sold'].sum().idxmax() print(f"Weekly Sales Summary") print(f"---------------------") print(f"Total Revenue: ${total_revenue}") print(f"Best-Selling Item: {best_selling_item}")
copy

When working with sales data for operational decisions, it is important to aggregate key metrics such as total revenue and units sold by item. Using pandas, you can easily group and sum data to pinpoint top performers. Visualizations like bar charts created with matplotlib make it easier to spot trends and communicate results to stakeholders. Always ensure your summary reports are clear, concise, and tailored to the needs of your audience.

Tehtävä

Swipe to start coding

Write a Python script to analyze and visualize weekly sales data for operations management decisions.

  • Calculate the total revenue for the week using the revenue column of the DataFrame.
  • Identify the best-selling item based on total units_sold for each item.
  • Plot a bar chart showing total units sold per item using matplotlib.
  • Print a summary report displaying the total revenue and the best-selling item.

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

some-alt