1. Data Preparation and Cleaning
Activity 1.01: Addressing Data Spilling
Solution:
- Import the pandas and copy libraries using the following commands:
import pandas as pd
import copy
- 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.
- 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:
Figure 1.60: First five rows of the DataFrame
- Look at the data types of sales using the following command:
sales.dtypes
You should get the following output:
Figure 1.61: Looking at the data type of columns of sales.csv
You can...