Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre 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.

Tâche

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.

Solution

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 5
single

single

Demandez à l'IA

expand

Demandez à l'IA

ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

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

Glissez pour afficher le menu

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.

Tâche

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.

Solution

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 5
single

single

some-alt