Aan de slagGa gratis aan de slag

Working with datasets - month totals

In this exercise, we will be exploring a dataset that has multiple sales in one month. We will create a script that will enable us to identify dates within the same month, and combine them into a new month total, and append this to the table.

We will be using the dataset df, which represents data from one of our sales areas. Print it out in the console to have a look at the data. As you can see, there were two sales in March. We will combine these sales into a single month total. We can iterate over the dataset using the .iteritems() method.

We will also be using the .split() method.

Deze oefening maakt deel uit van de cursus

Financial Forecasting in Python

Cursus bekijken

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Set the index to start at 0
index = ____

# Create the dictionary for the months
tt = {'____': 0, 'Feb': ____, '____': ____}
Code bewerken en uitvoeren