Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Plot Sales Moving Average | Automating Reports and Visual Insights
Python Automation for Reports and Visual Insights
Sektion 1. Kapitel 22
single

single

bookChallenge: Plot Sales Moving Average

Stryg for at vise menuen

Opgave

Swipe to start coding

Given a DataFrame containing columns for 'date' and 'sales', your task is to plot the original sales data and a 7-day moving average trend line on the same chart using matplotlib.

  • Calculate the 7-day moving average of the 'sales' column and store it as a new column in the DataFrame.
  • Plot the original sales values against their corresponding dates.
  • Plot the 7-day moving average values on the same chart.
  • Add axis labels and a title to the chart.
  • Add a legend to distinguish between the original sales and the moving average.

Løsning

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 1. Kapitel 22
single

single

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

some-alt