Git Product home page Git Product logo

rjbarker / home_sales Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 150 KB

Use PySpark and SparkSQL to execute SQL queries through a temporary view of the DataFrame created. Conduct additional queries on cached and partitioned data to determine runtime comparisons.

Jupyter Notebook 100.00%
big-data big-data-analytics cached large-scale partitioning pyspark pyspark-dataframes python sparksql

home_sales's Introduction

home_sales

Scenario

In this challenge, you'll use your knowledge of SparkSQL to determine key metrics about home sales data. Then you'll use Spark to create temporary views, partition the data, cache and uncache a temporary table, and verify that the table has been uncached.


Instructions

  • Rename the Home_Sales_starter_code.ipynb file as Home_Sales.ipynb.
  • Import the necessary PySpark SQL functions for this assignment.
  • Read the home_sales_revised.csv data in the starter code into a Spark DataFrame.
  • Create a temporary table called home_sales.
  • Answer the following questions using SparkSQL:
    • What is the average price for a four-bedroom house sold for each year? Round off your answer to two decimal places.
    • What is the average price of a home for each year it was built that has three bedrooms and three bathrooms? Round off your answer to two decimal places.
    • What is the average price of a home for each year that has three bedrooms, three bathrooms, two floors, and is greater than or equal to 2,000 square feet? Round off your answer to two decimal places.
    • What is the "view" rating for homes costing more than or equal to $350,000? Determine the run time for this query, and round off your answer to two decimal places.
      • Runtime: 0.3438713550567627 seconds
  • Cache your temporary table home_sales.
  • Check if your temporary table is cached.
  • Using the cached data, run the query that filters out the view ratings with an average price of greater than or equal to $350,000. Determine the runtime and compare it to uncached runtime.
    • Runtime: 0.34858036041259766 seconds
    • Comparison to the uncached runtime:
      • 0.0047 seconds slower
  • Partition by the "date_built" field on the formatted parquet home sales data.
  • Create a temporary table for the parquet data.
  • Run the query that filters out the view ratings with an average price of greater than or equal to $350,000. Determine the runtime and compare it to uncached runtime.
    • Runtime: 0.5417850017547607
    • Comparison to the uncached runtime:
      • 0.1979 seconds slower
  • Uncache the home_sales temporary table.
  • Verify that the home_sales temporary table is uncached using PySpark.
  • Download your Home_Sales.ipynb file and upload it into your "Home_Sales" GitHub repository.


References

Reference Name Description
edX Boot Camps LLC Dataset generation and starter files
PySpark PySpark is the Python API for Apache Spark. It enables you to perform real-time, large-scale data processing in a distributed environment using Python. It also provides a PySpark shell for interactively analyzing your data.

home_sales's People

Contributors

rjbarker avatar

Watchers

 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.