Summary

Resources

2018 Central Park Squirrel Census - Squirrel Data | NYC Open Data

Notes\ Code

image.png

Lets play with some data. In this case we will use the 2018 squirrel count of NYC central park. When we pull the CSV over from the Squirrel Census site we can see there's a ton here. This is good practice for what we see in the wild

image.png

Our challenge is to make a simple chart from the data using Pandas that has the sum of how many gray, red, and black hair squirrels are in Central Park and put it into a CSV like this.

image.png

Lets do it.

import pandas

data = pandas.read_csv("2018_Central_Park_Squirrel_Census_-_Squirrel_Data.csv")
series = data["Primary Fur Color"]
gray = int(series.str.count("Gray").sum())
red = int(series.str.count("Cinnamon").sum())
black = int(series.str.count("Black").sum())

data_dict = {
    "Fur Color": ["Gray", "Red", "Black"],
    "Count": [gray, red, black]
}

table = pandas.DataFrame(data_dict)
table.to_csv("squirrel_count.csv")

image.png

Easy peasy lemon squeezy.