Organizing the data

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 npimport pandas as pdimport pyodbcimport 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') ...

Get Data Science with SQL Server Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.