Appendix

1. Data Preparation and Cleaning

Activity 1.01: Addressing Data Spilling

Solution:

  1. Import the pandas and copy libraries using the following commands:

    import pandas as pd

    import copy

  2. Create a new DataFrame, sales, and use the read_csv function to read the sales.csv file into it:

    sales = pd.read_csv("sales.csv")

    Note

    Make sure you change the path (emboldened) to the CSV file based on its location on your system. If you're running the Jupyter notebook from the same directory where the CSV file is stored, you can run the preceding code without any modification.

  3. Now, examine whether your data is properly loaded by checking the first five rows in the DataFrame. Do this using the head() command:

    sales.head()

    You should get the following output: ...

Get Data Science for Marketing Analytics now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.