Advertisement
deniswhite77

Untitled

Feb 16th, 2022
1,747
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SPARK 0.54 KB | None | 0 0
  1. from pyspark.sql import SparkSession
  2.  
  3. APP_NAME = "DataFrames"
  4. SPARK_URL = "local[*]"
  5.  
  6. spark = SparkSession.builder.appName(APP_NAME) \
  7.         .config('spark.ui.showConsoleProgress', 'false') \
  8.         .getOrCreate()
  9.  
  10. taxi = spark.read.load('/datasets/pickups_terminal_5.csv',
  11.                        format='csv', header='true', inferSchema='true')
  12.  
  13. taxi = taxi.fillna(0)
  14.  
  15. taxi.registerTempTable("taxi")
  16.  
  17.  
  18. print(spark.sql("SELECT CAST(date As DATE),SUM(pickups) FROM taxi GROUP BY CAST(date As DATE) ORDER BY SUM(pickups) DESC").show(5))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement