I want to start this section by showing you some of Python's analytical and graphic capabilities. I am explaining the code just briefly here; you will learn more about Python data structures very quickly. Let's start coding! First, I need to import the necessary libraries:
import numpy as np
import pandas as pd
import pyodbc
import matplotlib.pyplot as plt
For the data I will analyze, I am using the data from the AdventureWorksDW2017 demo database, selecting from the dbo.vTargetMail view, like I did in Chapter 2, Introducing R, when I introduced the R language. I am also using ODBC to connect to SQL Server, with the same data source name and SQL Server login as I did then:
con = pyodbc.connect('DSN=AWDW;UID=RUser;PWD=Pa$$w0rd')
query = """SELECT CustomerKey,
Age, YearlyIncome,
CommuteDistance, BikeBuyer...