2. Data Exploration and Visualization
Activity 2.01: Analyzing Advertisements
Solution:
Perform the following steps to complete this activity:
- Import pandas and seaborn using the following code:
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
sns.set()
- Load the Advertising.csv file into a DataFrame called ads and examine if your data is properly loaded by checking the first few values in the DataFrame by using the head() command:
ads = pd.read_csv("Advertising.csv", index_col = 'Date')
ads.head()
The output should be as follows:
Figure 2.65: First five rows of the DataFrame ads
- Look at the memory usage and other internal information about the DataFrame using the following command:
ads.info
This gives the following output:
Figure 2.66: The result of ads.info()
From the preceding figure, you can see that you have five columns with 200 data points in each and no missing values.
- Use describe() function to view basic statistical details...