Professional Documents
Culture Documents
Pricing
Made by :
Mohamed Selim Maazouz
Mohamed Tegedi
Fatma Sakka
Index 1 Dynamic Pricing
2 What is Spark ?
5
Transformation And Actions Examples
6 Demo
7 Conclusion
Dynamic Pricing
Dynamic Pricing is a pricing strategy in which companies set flexible prices for products or
services based on current market demands.
6.Clean up: When you are finished with your Spark job, make sure to clean
up any resources that were used.
Transformation And Actions Examples
Difference between Transformations and Actions ?
Transformations : which create a new dataset from an existing one, and
Actions : which return a value to the driver program after running a computation on the dataset
Transformation And Actions Examples
Transformations:
1. map: Applies a function to each element of an RDD or DataFrame and returns a new RDD or
DataFrame with the results.
2. filter: Selects elements from an RDD or DataFrame that satisfy a given predicate and returns a
new RDD or DataFrame with the selected elements.
3. flatMap: Similar to map, but each input element can be mapped to zero or more output
elements, resulting in a new RDD or DataFrame with more elements than the original.
4. groupBy: Groups elements of an RDD or DataFrame by a given key and returns a new RDD or
DataFrame where the values are grouped together for each key.
5. join: Joins two RDDs or DataFrames based on a common key.
Transformation And Actions Examples
Actions:
1. collect: Returns all the elements of an RDD or DataFrame to the driver
program as an array.
2. count: Returns the number of elements in an RDD or DataFrame.
3. reduce: Applies a function to the elements of an RDD or DataFrame to
reduce them to a single value.
4. save: Saves the RDD or DataFrame to a file or storage system.
Demo
Demo
Demo
Demo
Demo
Demo
Demo
Demo
Demo
Commands used :
val flight=sc.textFile("C:/flights.csv")
val booking=sc.textFile("C:/booking.csv")
flight.collect()
booking.collect()
flight.foreach(println)
booking.foreach(println)
val flight = spark.read.format("csv").load("C:/flights.csv")
val flights=flight.toDF("flight_number","departure","arrival","date","number_of_passengers")
flights.show
Demo
Rest of the Commands used :
val booking = spark.read.format("csv").load("C:/booking.csv")
val bookings=booking.toDF("passport_id","flight_number","price")
bookings.show()
val join = bookings.join(flights,"flight_number")
join.show()
flights.createOrReplaceTempView("table_of_flights")
bookings.createOrReplaceTempView("table_of_bookings")
spark.sql("select min(price) from table_of_bookings").show
Conclusion
In conclusion, dynamic pricing has emerged as a valuable tool for businesses to optimize
revenue in the era of big data. By leveraging large datasets and advanced analytics
techniques, businesses can dynamically adjust their pricing strategies in real-time, based on
factors such as consumer demand, competitor pricing, and market trends. However,
implementing dynamic pricing requires careful consideration of ethical concerns and
transparency to ensure fairness to consumers. As big data continues to evolve, dynamic
pricing will likely become even more prevalent, and businesses will need to adapt and
innovate to stay competitive.
Thank you for your attention