Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
This branch is 15 commits behind jvns:master.

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Pandas cookbook

pandas is a Python library for doing data analysis. It's really fast and lets you do exploratory work incredibly quickly.

The goal of this cookbook is to give you some concrete examples for getting started with pandas. The docs are really comprehensive. However, I've often had people tell me that they have some trouble getting started, so these are examples with real-world data, and all the bugs and weirdness that entails.

I'm working with 3 datasets right now

  • 311 calls in New York
  • How many people were on Montréal's bike paths in 2012
  • Montreal's weather for 2012, hourly

It comes with batteries (data) included, so you can try out all the examples right away.

Table of Contents

How to use this cookbook

You'll need an up-to-date version of IPython Notebook (>= 3.0) and pandas (>=0.13) for this to work properly. It's set up to work with Python 2.7.

You can get these using pip:

pip install ipython pandas numpy tornado pyzmq jinja2 matplotlib

This can be difficult to get set up and require you to compile a whole bunch of things. I instead use and recommend Anaconda, which is a Python distribution which will give you everything you need. It's free and open source.

Once you have pandas and IPython, you can get going!

git clone
cd pandas-cookbook/cookbook
ipython notebook

A tab should open up in your browser at http://localhost:8888

Happy pandas!

Running the cookbook inside Docker container.

This repository contains Dockerfile and can be build into a docker container. To build the container run following command from inside of the repository directory:

docker build -t jvns/pandas-cookbook .

run the container:

docker run -d -p 8888:8888 -e "PASSWORD=MakeAPassword" <IMAGE ID>

you can find out about the id of the image, by checking

docker images

After starting the container, you can access ipython notebook with the cookbook on port 8888. Remember to use https and authenticate with MakeAPassword.

https://<docker ip>:8888


If you see something wrong, or there's something you'd like to learn that I haven't explained here, or there's something you know about that you would like to share, create an issue! Send me email! Send a pull request!


  • Joining dataframes
  • Using stack/unstack
  • ???


Creative Commons License

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License


There's a translation into Chinese of this repo.


Recipes for using Python's pandas library






No packages published


  • Jupyter Notebook 100.0%