Giter Site home page Giter Site logo

ride-share's Introduction

Work with Ride Share Data using Arrays and Hashes

At a Glance

Introduction

Rideshare Programs are systems that help people organize carpooling/vanpooling. Some popular on-demand rideshare apps, like Lyft and Uber, store and use data on riders, drivers, and trips, particularly data on when a trip happened, who was the driver, and who was the rider.

Learning Goals

  • Logically order data into a nested data structure
  • Understand benefits of organizing data in a nested structure
  • Iterate through a nested data structure to return specific information

Objective

We will look at data of drivers of a rideshare service and their ride history. We want to be able to see how many rides each driver has given and how much money a driver has made.

Currently, the data is stored in a CSV file. In this assignment, you should take this data and thoughtfully organize it into a nested data structure that uses both arrays and hashes.

But why?

Given some data, a programmer often needs to be able to read, parse, and work with that data structure. Data that is organized into nested arrays and hashes can make this work easier. Ideally, data that is very well-organized will make this work easier to write, easier to read, and produce cleaner, higher-quality code.

The most common way you'll see data represented is in JSON. We'll learn more about JSON more in depth later, but what you need to know now is that data is often represented with several layers of nested data structures, ultimately making up one big data structure. If we practice working with nested data structures now, it will make working with JSON later easier!

Have a look at this example of JSON from Google Maps (Source) and answer the following questions.

  • How many different layers of data structures are there?
  • What data structures were used?
  • Why were those data structures used for those layers?

Let's do this!

Use the file worksheet.rb to complete this activity. Open up this file, and type your answers below each prompt. We will not be turning this assignment in, so feel free to write any comments or thoughts within this file!

Step 1: Establish the layers

Based on the data provided in the rides.csv, make a list of the different layers our data structure will need. These layers will each represent a new data structure that will nested within another.

Step 2: Assign a data structure to each layer

Now that you know what layers you have, decide what data structure would be most appropriate to use for each layer.

After this point, consult with a neighbor.

Step 3: Make the data structure!

Create the data structure by starting with the outline, then manually input all the data from rides.csv into it.

Be mindful of indentation! Proper indentation will make reading data substantially easier as the data becomes more nested.

Step 4: Total Driver's Earnings and Number of Rides

Iterate through the data structure to display, by printing in terminal, the following info:

  • The number of rides each driver has given
  • The total amount of money each driver has made
  • The average rating for each driver
  • Which driver made the most money?
  • Which driver has the highest average rating?

Optionally, print in the terminal:

  • For each driver, on which day did they make the most money?

Wrap up

By having this data structure, we can now more easily target specific parts of our data to see how many rides a driver has given.

ride-share's People

Contributors

tildeee avatar pilgrimmemoirs avatar kariabancroft avatar jacquelynoelle avatar vertige avatar cheezitman avatar

Watchers

James Cloos 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.