Homework 3 — Blue Bikes
Introduction
Bluebikes is a public bike share system in the Boston metropolitan area. In this assignment, you'll analyze trip data from the Bluebikes system to practice working with tables, filtering data, creating visualizations, and transforming columns.
For this assignment, you'll be working with a CSV file containing information about Bluebikes trips. The file "bluebikes-data.csv" contains the following columns:
duration
: Length of the trip in secondsstart-station-name
: Name of the station where the trip beganstart-station-latitude
: Latitude coordinate of the starting stationstart-station-longitude
: Longitude coordinate of the starting stationend-station-name
: Name of the station where the trip endedend-station-latitude
: Latitude coordinate of the ending stationend-station-longitude
: Longitude coordinate of the ending station
Problem 1
Load the Bluebikes data from the CSV file into a table. Define a table called bike-table
with the appropriate column names and types
Problem 2
Many commuters use Bluebikes to travel between specific locations. Create a new table called porter-square-trips
that contains only the trips that started at "Danehy Park" and ended at "Porter Square Station".
Problem 3
Trip durations can vary widely. Design a function called duration-category
that takes a row from the bike table and returns a string categorizing the trip duration as "short", "medium", or "long" based on the following criteria:
- "short": less than 300 seconds
- "medium": between 300 and 500 seconds (inclusive)
- "long": greater than 500 seconds
Include a proper doc:
string that explains what the function does.
Then, use the build-column
function to create a new table called categorized-durations
that adds a "category" column to the original bike-table
.
Finally, create a bar chart called duration-bar-chart
that displays the frequency of each duration category.
Problem 4
For better readability, it's often helpful to convert trip durations from seconds to minutes. Design a function called seconds-to-minutes
that takes a number of seconds and returns the equivalent number of minutes. Include a doc:
string and test cases in a where:
block to demonstrate that your function works correctly.
Then, create a new table called table-with-minutes
that replaces the "duration" column in the original bike-table
with durations in minutes.