Class 1 in-class exercise

Class 1 in-class exercise#

We’ll be doing calculations on 2021 Yellow Taxi Trips data. We’ll live-code this together.

Step 0#

The data needs to available on the machine where Python is running in order to process it, so let’s download from the NYC Open Data site directly:

!wget -O 2021_yellow_taxi_trips.csv --no-verbose https://data.cityofnewyork.us/resource/m6nq-qud6.csv
2024-04-25 10:43:56 URL:https://data.cityofnewyork.us/resource/m6nq-qud6.csv [136065] -> "2021_yellow_taxi_trips.csv" [1]

This is using a command-line program to do the downloading. We’ll download data ourselves manually later. Look at the files in the current directory:

!ls

You should see 2021_yellow_taxi_trips.csv there.

Step 1#

Print out the trip distances.

# your code here

Step 2#

Calculate the average ride distance.

# your code here

Step 3#

Your turn! Calculate the percent of trips that were paid for by credit card. The data dictionary will be helpful - see the Attachment on the dataset page.

# your code here