Get startedGet started for free

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.

This exercise is part of the course

Financial Forecasting in Python

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Set the index to start at 0
index = ____

# Create the dictionary for the months
tt = {'____': 0, 'Feb': ____, '____': ____}
Edit and Run Code