Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

A Quick Aside About Data

Anytime you are exploring a new visualization library, it’s a good idea to start with some data in a domain you are familiar with. The beauty of Bokeh is that nearly any idea you have should be possible. It’s just a matter of how you want to leverage the available tools to do so.

The remaining examples will use publicly available data from Kaggle, which has information about the National Basketball Association’s (NBA) 2017-18 season, specifically:

You can download the data files from the Real Python GitHub repo.

Create a new subdirectory name data inside the the Bokeh directory you created earlier, and save the files there. Bokeh/data/

  • 2017-18_playerBoxScore.csv: game-by-game snapshots of player statistics
  • 2017-18_teamBoxScore.csv: game-by-game snapshots of team statistics
  • 2017-18_standings.csv: daily team standings and rankings

File: read_nba_data.py

import pandas as pd 

# Read the csv files
player_stats = pd.read_csv('data/2017-18_playerBoxScore.csv',
                           parse_dates=['gmDate'])
team_stats = pd.read_csv('data/2017-18_teamBoxScore.csv',
                          parse_dates=['gmDate'])
standings = pd.read_csv('data/2017-18_standings.csv',
                         parse_dates=['stDate'])

Comments & Discussion

sion on May 27, 2019

2017-18_teamBoxScore.csv’ downloads correctly from gitub. 2017-18_playerBoxScore.csv and 2017-18_teamBoxScore.csv only show the raw data without column headings and on the screen. So far I have been unable to find these files in Kaggle Any assistance to obtain these files will be welcome.

Chris Bailey RP Team on May 28, 2019

Hi Sion, I have a temporary solution, and will work on something more permanent. If you use this Real Python github materials link you can download the materials as a zip file, using the large green button on the right side. The path inside the unzipped folder will be: materials-master/intro-to-bokeh/data/ .

Dan Bader RP Team on May 28, 2019

@sion: You can also try this link which should download a zip file that only includes the CSVs from the repo, but not the rest of the code and the other projects.

Pygator on Aug. 18, 2019

I literally had no idea you could import * from a file like that inside a repl session and inspect the variables. i may have been using jupyter notebooks for too long

Become a Member to join the conversation.