Make a Punchcard Plot with Seaborn | by Lee Vaughan | Sep, 2023

Quickly identify cyclical trends

A mechanical punch clock next to a rack of timecards.
A punch clock with timecards (image by Hennie Stander on UnSplash)

A punchcard plot, also called a table bubble chart, is a type of visualization for highlighting cyclical trends in data. It displays data in a rigid matrix o grid format, usually composed of days of the week versus hours of the day. Circles represent data points at the intersections of the rows and columns and their size conveys the data value. Color can be used to include additional information.

A table bubble plot (image by author)

The name “punchcard” is an allusion to old-timey “timecards” that workers would stamp or “punch” in a machine to record their comings and goings.

To build a punchcard plot, you need timestamped data. In this Quick Success Data Science project, we’ll use a Kaggle dataset to track the times when bicycles are rented in Washington, D.C.

The Kaggle Bike Sharing in Washington D.C. Dataset contains the hourly and daily count of bikes rented in 2011 and 2012 in the Capital bikeshare system in Washington, D.C. [1]. This data is released under a CC0 1.0 license. For details about the dataset contents visit the readme file.

For convenience, I’ve already downloaded this data to a public Gist.

Besides Python, you’ll need the pandas data analysis library and the seaborn plotting library. You can install them with:

conda install pandas seaborn


pip install pandas seaborn

The following commented code was written in JupyterLab and is described by cell.

Importing Libraries and Loading the Data

After importing matplotlib and seaborn for plotting and pandas for data analysis, we’ll read the CSV file of rental data into a pandas DataFrame, keeping only the columns for the season of the year, the weekday, the hour, and the count (number of rentals).

Enlace fuente

Deja una respuesta

Su dirección de correo electrónico no será publicada. Los campos obligatorios están marcados *

Puede utilizar estas etiquetas y atributos HTML : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>