Exploring a dataset with pandas and matplotlib
In this first recipe, we will show how to conduct a preliminary analysis of a dataset with pandas. This is typically the first step after getting access to the data. pandas lets us load the data very easily, explore the variables, and make basic plots with matplotlib.
We will take a look at a dataset containing all ATP matches played by four tennis players until 2012. Here, we will focus on Roger Federer.
Getting ready
Download the Tennis dataset from the book's GitHub repository at https://github.com/ipython-books/cookbook-data, and extract it to the current directory.
How to do it...
- We import NumPy, pandas, and matplotlib:
In [1]: import numpy as np import pandas as pd import matplotlib.pyplot as plt ...
Get IPython Interactive Computing and Visualization Cookbook 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.