Coder Social home page Coder Social logo

vlfom / nyc-taxi-data Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 2.7 MB

Code for fetching, sampling, and analysis of NYC taxi data from TLC and Uber for 2009-2018

Jupyter Notebook 99.27% Shell 0.73%
nyc-taxi-dataset nyc-taxi taxi-data uber-data dask-distributed jupyter-notebook

nyc-taxi-data's Introduction

NYC taxi rides 2009-2018 fetching & analysis using TLC and Uber datasets

Code for downloading the data of NYC taxi trips for the years of 2009-2018 and creating a representative 2% ~500MB .parquet sample for the subsequent analysis (can be used with Pandas and Dask).

Data sources

Data preparation

All scripts must be run from setup/scripts directory.

  1. Download TLC 2009-2018 data by running setup/scripts/download_raw_tlc_data.sh.
  2. Download Uber 2014 data by running setup/scripts/download_raw_uber_data.sh.
  3. Clean dirty rows from TLC data by running remove_bad_rows.sh

Many steps were taken from https://github.com/toddwschneider/nyc-taxi-data.

Data processing & sampling

In analysis/Merge and sample data.ipynb the csvs are loaded and merged using the Dask library. For TLC data from 2009 until June 2016 and for Uber data from Apr-Sep 2014 we have lat/long coordinates, so those are merged with geozones of NYC taxi zones (see the bottom of TLC webpage) using geopandas library. They could also be merged with NYC tracts if you uncomment some blocks of code (or with any other shapes). The shapefiles for taxi zones and tracts are located in data/shapefiles.s

After merging the datasets and joining locations with zones/tracts, 2% sampling is performed and only pickup_datetime, dropoff_datetime, pickup_taxizone, dropoff_taxizone, trip_type (where trip_type โˆˆ {fhv, green, yellow, uber) columns are kept. This in the end results in ~500MB dataset when stored in .parquet format or in 45,396,200 trips.

Some steps were taken from https://github.com/r-shekhar/NYC-transport.

Data analysis

In analysis/Analyze data.ipynb the 2% sample is loaded from .parquet file into a Dask dataframe and some exemplar analysis is performed. You can check the yearly distribution of rides and monthly counts for different ride types.

rides monthly by type

nyc-taxi-data's People

Contributors

vlfom avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.