import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
# Data set used in this exercise
data_filename = 'Advertising.csv'
# Read advertising.csv file using the pandas library
df = pd.read_csv(data_filename)
# Get a quick look of the data and columns
df.head()
### edTest(test_pandas) ###
# Select the first 7 rows
df_new = df.iloc[:7]
# Print your new dataframe to see if you have selected 7 rows correctly
print(df_new)
TV Radio Newspaper Sales
0 230.1 37.8 69.2 22.1
1 44.5 39.3 45.1 10.4
2 17.2 45.9 69.3 9.3
3 151.5 41.3 58.5 18.5
4 180.8 10.8 58.4 12.9
5 8.7 48.9 75.0 7.2
6 57.5 32.8 23.5 11.8
# Use a scatter plot for TV vs Sales
plt.scatter(df_new.TV,df_new.Sales)
# Add axis labels for clarity (x : TV budget, y : Sales)
plt.xlabel('TV')
plt.ylabel('Sales')
# Use a scatter plot for TV vs Sales
plt.scatter(df.TV,df.Sales)
# Add axis labels for clarity (x : TV budget, y : Sales)
plt.xlabel('TV')
plt.ylabel('Sales')