5. Predicting Customer Revenue Using Linear Regression
Activity 5.01: Examining the Relationship between Store Location and Revenue
Solution:
- Import the pandas, pyplot from matplotlib, and seaborn libraries. Read the data into a DataFrame called df and print the top five records using the following code:
import pandas as pd
import matplotlib.pyplot as plt, seaborn as sns
df = pd.read_csv('location_rev.csv')
df.head()
Note
Make sure you change the path (highlighted) 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.
The data should appear as follows:
Figure 5.35: The first five rows of the location revenue data
You see that, as described earlier, you have the revenue of the store, its age, along with various fields about the location of the store. From the top five records, you get a sense of the order of the values...