Successfully reported this slideshow.
Upcoming SlideShare
×

How to use Map() Filter() and Reduce() functions in Python | Edureka

78 views

Published on

** Python Certification Training: https://www.edureka.co/data-science-python-certification-course**
This Edureka PPT on 'map, filter, and reduce functions in Python' is to educate you about these very important built-in functions in Python. Below are the topics covered in this PPT:

Introduction to map filter reduce
The map() function
The filter() function
The reduce() function
Using map(),filter() and reduce() functions together
filter() within map()
map() within filter()
map() and filter() within reduce()

Follow us to never miss an update in the future.
Instagram: https://www.instagram.com/edureka_learning/
Castbox: https://castbox.fm/networks/505?country=in

Published in: Technology
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

How to use Map() Filter() and Reduce() functions in Python | Edureka

2. 2. ➢ Introduction to map() filter() reduce() ▪ The map() function ▪ The filter() function ▪ The reduce() function ➢ Using map() filter() and reduce() together www.edureka.co/python ▪ filter() within map() ▪ map() within filter() ▪ filter() and map() within reduce()
3. 3. Introduction to map(), filter() and reduce() www.edureka.co/python
4. 4. Applies a given function to all the iterables and returns a new list Creates an output list consisting of values for which the function returns true Applies a given function to the iterables and returns a single value map() filter() reduce() Introduction to map(), filter() and reduce() www.edureka.co/python
5. 5. www.edureka.co/python
6. 6. 1 2 3 4 map(): Applies a given function to all the iterables and returns a new list. output = map(lambda x: x+3 , [1,2,3,4]) www.edureka.co/python
7. 7. 1 2 3 4 map(): Applies a given function to all the iterables and returns a new list. output = map(lambda x: x+3 , [1,2,3,4]) www.edureka.co/python
8. 8. 1 2 3 4 4 5 6 7 map(): Applies a given function to all the iterables and returns a new list. output = map(lambda x: x+3 , [1,2,3,4]) www.edureka.co/python
9. 9. www.edureka.co/python
10. 10. filter() Used to filter the given iterables(lists, sets, etc) with the help of another function passed as an argument to test all the elements to be true or false. output = map(lambda x: (x>=3) , [1,2,3,4]) 1 2 3 4 www.edureka.co/python
11. 11. filter() Used to filter the given iterables(lists, sets, etc) with the help of another function passed as an argument to test all the elements to be true or false. output = map(lambda x: (x>=3) , [1,2,3,4]) 1 2 3 4 www.edureka.co/python
12. 12. filter() Used to filter the given iterables(lists, sets, etc) with the help of another function passed as an argument to test all the elements to be true or false. output = map(lambda x: (x>=3) , [1,2,3,4]) 1 2 3 4 3 4 www.edureka.co/python
13. 13. www.edureka.co/python
14. 14. output = map(lambda x,y: x+y, [1,2,3,4]) reduce(): Applies some other function to a list of elements that are passed as a parameter to it and finally returns a single value. 1 2 3 4
15. 15. output = map(lambda x,y: x+y, [1,2,3,4]) reduce(): Applies some other function to a list of elements that are passed as a parameter to it and finally returns a single value. 1 2 3 4 3 www.edureka.co/python
16. 16. output = map(lambda x,y: x+y, [1,2,3,4]) reduce(): Applies some other function to a list of elements that are passed as a parameter to it and finally returns a single value. 1 2 3 4 3 6 www.edureka.co/python
17. 17. output = map(lambda x,y: x+y, [1,2,3,4]) reduce(): Applies some other function to a list of elements that are passed as a parameter to it and finally returns a single value. 1 2 3 4 3 6 10 www.edureka.co/python
18. 18. www.edureka.co/python
19. 19. c = map(lambda x:x+x, )filter(lambda x: (x>=3), (1,2,3,4)) www.edureka.co/python
20. 20. 1 2 3 4 3 443 filter(lambda x: (x>=3), (1,2,3,4)) c = map(lambda x:x+x, ) www.edureka.co/python
21. 21. ,( ) ) 1 2 3 4 3 4 43c = map(lambda x:x+x, filter(lambda x: (x>=3), (1,2,3,4)) www.edureka.co/python Filters out integers >=3 resulting in [3,4], then maps this using (x+x) condition, you will get [6,8], which is the output.
22. 22. www.edureka.co/python
23. 23. c = filter(lambda x: (x>=3), )map(lambda x:x+x, (1,2,3,4)) www.edureka.co/python
24. 24. c = filter(lambda x: (x>=3), ) map(lambda x:x+x, (1,2,3,4)) 2 3 4 5 6 7 1 4 www.edureka.co/python
25. 25. map(lambda x:x+x, (1,2,3,4)) 1 2 3 4 c = filter(lambda x: (x>=3), )4 5 6 7( )), , , www.edureka.co/python
26. 26. www.edureka.co/python
27. 27. d = reduce ( lambda x, y: x+y, )map ( lambda x:x+x, filter ( lambda x: (x>=3) , (1,2,3,4))) www.edureka.co/python
28. 28. d = reduce ( lambda x, y: x+y, ) map ( lambda x:x+x, filter ( lambda x: (x>=3) , (1,2,3,4))) 1 2 3 4 3 443 86 www.edureka.co/python
29. 29. d = reduce ( lambda x, y: x+y, ) map ( lambda x:x+x, filter ( lambda x: (x>=3) , (1,2,3,4))) 1 2 3 4 3 443 86( , )) www.edureka.co/python