From the course: Scala Essential Training for Data Science

Unlock this course with a free trial

Join today to access over 25,000 courses taught by industry experts.

Applying lambda functions to datasets

Applying lambda functions to datasets

- [Instructor] Okay, I'd like to continue where we left off in the last video. So we have created a dataset called Product Dataset. And now what I'd like to do is show you an example of how we can use Lambda functions, which are a common pattern used in functional programming to filter or work with datasets. So I'm just going to paste in a line here where we're going to create a new value called Premium Products DS. And we're going to operate on our products DS dataset, and we're going to apply a filter. Now, the filter we're going to apply is actually a Lambda function. And you can notice the notation here where we're passing in P, which is some parameter. And that parameter P is going to be associated with each of the rows in the dataset. So for each of those rows, which is going to basically take on or be assigned to the variable P, we're going to look at the price of that and determine if it's greater than 20. And if that product is also in stock, then the Boolean will be true. So…

Contents