U.S. Healthcare Associated Infections ( HAIs ) using CDC public data

I just finished my @CDCgov data story about Healthcare Associated Infections ( #HAIs ) using D3. These infections are particularly nasty as they are antibiotic-resistant. I’ve created an interactive map of the U.S. with the total number of infections per state and the rate of infection per 1000 people for the latest available year, 2014. If CDC funding continues to be cut, it is unknown when the next HAI updates will be made.

Check it out here: http://www.peterbakke.com/bits/cdc-hai/

Image: CDC

Excel and .csv lesson learned… Includes painful waste of time, unfortunately.

I found out that when you export data in .csv format from #Excel make sure you don’t have a trailing space after any column names. They are exported as “col_name ” with the space AND quotes. Beware when using them to index your array! They will fail. Simply delete any hidden spaces in your column names before exporting. Please. For your own sanity. #DataAnalytics #ERROR #painful lesson.

Peter Bakke DOH!

Debugging Javascript – one useful tool

Here’s an idea for displaying those pesky ephemeral variables that come and go like ghosts in JavaScript. Check this out. I
want to know if I’m reading in a CSV file properly or not. You can use for any variable / array / object.


// Read in a .csv file
d3.csv(“../datafile.csv”, function(someData) {


function debugMe(whateverData) {

// ‘Sum Ages’ is a variable in row zero of passed var ‘whateverData’
document.getElementById(“debug”).innerHTML = “Debug: ” + whateverData[0][‘Sum Ages’].toString()


<p id=”debug”></p>

Python Immutable strings, integers, booleans

In Python, STRINGS, INTS, BOOLs etc. are IMMUTABLE… meaning, for example, that you cannot convert a df column that is a string to a column that is int.  However,  you can ASSIGN the values (objects) to another variable or create a new instance of that column in another dataframe   … or use .astype(int) to perform an intermediate computation.


Local Host Error .. Closing Windows CMD window = not good!

FYI all users of Windows. I discovered that my local web server stopped working when I closed my Windows CMD window. I use the following command line to start up a local web server: python -m SimpleHTTPServer.

Makes sense, I suppose, that the web server craps out when the CMD window is closed, but it took moi quite a while to figure out why my local web-served data visualization file worked one minute and I got an error the next minute (http://localhost:8000/basic_charts.html Error message: This site can’t be reached … localhost refused to connect ).

Reason: I had closed the Windows CMD window somehow, somewhere along the way!  Newbie Noob error. Oh, well. Still learning!newbie here - Peter Bakke