Тёмный

#43 Python Tutorial for Beginners | Filter Map Reduce 

Telusko
Подписаться 2,4 млн
Просмотров 585 тыс.
50% 1

Check out our courses:
Spring and Microservices Weekend Live Batch : bit.ly/spring-...
Coupon: TELUSKO10 (10% Discount)
Master Java Spring Development : bit.ly/java-sp...
For More Queries WhatsApp or Call on : +919008963671
website : courses.telusk...
Instagram : / navinreddyofficial
Linkedin : / navinreddy20
TELUSKO Android App : bit.ly/TeluskoApp
Discord : / discord
In this lecture we will learn:
Filter Map and Reduce in Python
Use of filter(), map() and reduce() functions
How lambda function can be used with filter map and reduce
Syntax of Filter, Map and reduce function
Difference between filter(), map() and reduce() functions
#1
Lambda function can be used with these three functions:
1. filter()
2. map()
3. reduce()
#2
filter() function will take a list and do filtering and give values.
filter() takes a sequence and also returns a sequence.
filter() function takes two arguments: function and iterable.
filter(func, iterable)
We have to give the definition of a function that we have passed as a condition in an argument.
The defined function should return a value of either True or False based on the condition.
Then, filter() will take the value that is returned by the defined function and does perform filtering based on this value.
In the defined function, we need only two things i.e, a variable and an expression. So, we can also use the lambda function instead of using the normal function to define the condition for a filter.
-Lambda reduces the number of lines of code and makes it more precise.
Filter() simply returns the iterable passed to it.
#3
map() function is used when we want to change the value of every element of a list.
map() function also takes two arguments i.e., a function and an iterable.
map(func, *iterables)
To get the result as a list, the built-in list() function can be called on the map object.
We have to define a function that we have passed as a condition in an argument.
The defined function should return any value.
The lambda function can also be used in an argument as a function instead of defining the normal function for the logic.
map() function returns a list. The function returns a map object which is a generator object.
#4
reduce() function is used to reduce the number of values from a list.
reduce() function belongs to a module known as functools.
We have to import the module functools from the library to use the reduce function.
reduce() also take two arguments i.e., a function and a sequence.
reduce(func, iterable[, initial])
We have to give the definition of a function that we have passed as a condition in an argument.
The lambda function can also be used in an argument as a function instead of defining the normal function for the logic.
Python Tutorial to learn Python programming with examples
Complete Python Tutorial for Beginners Playlist : • #1 Python Tutorial for...
Python Tutorial in Hindi : • #1 Python Tutorial | I...
Github :- github.com/nav...
Java and Spring Framework For beginners with Spring Boot : - bit.ly/3LDMj8D
Java Tutorial for Beginners (2023) :- bit.ly/3yARVbN
Editing Monitors :
amzn.to/2RfKWgL
amzn.to/2Q665JW
amzn.to/2OUP21a.
Subscribe to our other channel:
Navin Reddy : www.youtube.co....
Telusko Hindi :
www.youtube.co....
Donation:
PayPal Id : navinreddy20
Patreon : navinreddy20
www.telusko.com...

Наука

Опубликовано:

 

3 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 438   
@vikrantthakur3818
@vikrantthakur3818 4 года назад
Finally found a cool programmeer who teaches these concepts in best possible way❤❤😇 Thanks navin sir
@NitinJainNoida
@NitinJainNoida 5 лет назад
Know what is the difference between filter, reduce and map: map: Takes a function f, and a list L1, and returns a list L2 obtained by applying f to every element of L1. Say f is a function that takes x and returns 2x. Then, map(f, [1,2,3,4]) returns [2,4,6,8]. reduce: Takes a binary operator f, a list L and a seed value (or identity element). It returns the seed value if the list is empty. Otherwise, it applies the binary operator f to the seed and first element of L, then applies f to the result of this and the 2nd element of L, and so on till L is exhausted. The result is returned. This can be seen as a generalization of factorial function. filter: Takes a boolean function f and a list L1. It applies the function to each element of L1, and list of those elements that give true is returned. #insmot
@kirubhaharkannan5461
@kirubhaharkannan5461 3 года назад
Awesome
@mandvi8887
@mandvi8887 3 года назад
map function always returns an object. One need to convert to list explicitly.
@bountyhead5537
@bountyhead5537 2 года назад
Thanks brother
@kogurwarsrisai6947
@kogurwarsrisai6947 2 года назад
didn't get about reduce function
@SumanGorkhali-z1k
@SumanGorkhali-z1k Год назад
Perfect
@muskaan3206
@muskaan3206 5 лет назад
Sir, you have made boring topics interesting for us..i love your teaching method..Great job!!
@sunilmaurya3815
@sunilmaurya3815 4 года назад
the form of steps u choose while teaching is unique and more understandable as compared to other lecturers thank u sir great explanation☺️
@nehaaadarsh
@nehaaadarsh 4 года назад
Lambda is my new crush ,😍😍❤️❤️ I love lambda
@sidskywalker8423
@sidskywalker8423 4 года назад
Indeed!
@intelligentbrahman1572
@intelligentbrahman1572 3 года назад
really pandey g,....i am also pandey............are u student??
@hemajeyalakshmi9106
@hemajeyalakshmi9106 3 года назад
oh god! you are simply answering all the questions that pop my head. thank you navin. you have no idea what a great part you are holding in my life. because of you, im fearless and ready to learn programming. thank you for saving my life.
@swarnimasingh1232
@swarnimasingh1232 5 лет назад
"that's what programmers do, making things cool" and how cool he looks with that action ;)
@harshwardhansingh617
@harshwardhansingh617 3 года назад
makkhan lagana band karo rre xD
@webcreationstudio7088
@webcreationstudio7088 3 года назад
@@harshwardhansingh617 lol tum toh bare heavy driver ho
@divyeshkumarbalar7732
@divyeshkumarbalar7732 5 лет назад
i was married to java and its version 8 features; after watching this i am planning to cheat in my relationship
@mukeshcheemakurthi7933
@mukeshcheemakurthi7933 5 лет назад
you will be presented in the court if you do this :)
@divyeshkumarbalar7732
@divyeshkumarbalar7732 5 лет назад
I will stay faithful to both Ill treat java as a friend (friendzoned)
@sravanichowdary7755
@sravanichowdary7755 4 года назад
😝
@sumaiyathameem5888
@sumaiyathameem5888 4 года назад
😃
@INDIAN-kq6yo
@INDIAN-kq6yo 4 года назад
Java will divorce you
@mohittrivedi1112
@mohittrivedi1112 6 лет назад
Seriously your Python videos are amazing. kudos to you
@SumanGorkhali-z1k
@SumanGorkhali-z1k Год назад
such a headache of lambda syntax clarified so simply. Thankx.
@wqwerisk2895
@wqwerisk2895 Месяц назад
Thank you! Wishing you all the best 🙏🏼
@Vikranth4A5
@Vikranth4A5 6 лет назад
Navin sir can u make more videos and more concepts as soon as possible because we are understand very easy with ur explaination NOTE : TRY TO MAKE SOME PROJECTS AND SOFTWARE USING THIS CONCEPTS
@DirisalaSandeepKumar
@DirisalaSandeepKumar 9 дней назад
demanding huh.....
@allofmystuffs
@allofmystuffs 4 года назад
Legend says, the hardest part of programming is naming the variables.
@sathvikmalgikar2842
@sathvikmalgikar2842 2 года назад
finally found a good tutor who does'nt just dump all the codes and and leave logic behind completely making it boring and useless to watch. really amazing sir.
@NitinJainNoida
@NitinJainNoida 5 лет назад
In case anyone need more information about the difference between filter, map and reduce: Difference 1: 1. 'Map' takes all objects in a list and allows you to apply a function to it. The result is usually the same quantity of items as in the main list but with some execution(as specified in the function). 2. 'Filter' takes all objects in a list and runs that through a function to create a new list with all objects that return True in that function. Not necessary that it will output same number of items as present in the main list. Difference 2: 1. In Map you can use multiple iterables definition : map(function_object, iterable1, iterable2,...) 2. Whereas in filter only one iterable can be used definition : filter(function_object, iterable) Difference 3: Further in filter the function_object has to return boolean only. Hope it helps! :) #insmot
@rahulvaswani8866
@rahulvaswani8866 5 лет назад
thanks a lot
@islamgoher
@islamgoher 5 лет назад
Hey, Thanks for this clarification. but, you didn't mention the purpose of reduce function there :)
@vivekpandey5142
@vivekpandey5142 Год назад
It's helpful
@RaiyanAlphaRanger
@RaiyanAlphaRanger 3 года назад
This is so amazing! I learnt a whole lot about not just lambda from this video, but also these three other useful (albeit advances) functions! Thank you so much!
@hrutikdhumal402
@hrutikdhumal402 4 года назад
this is one of the best python tutorial series for begineers and the main part is it is free thank you sir
@swethagopu3708
@swethagopu3708 4 года назад
Your smart explanation helps me to get out of my fear in learning python😍😍😍
@zakiasmaa6834
@zakiasmaa6834 Месяц назад
"that's what programmers do, making things cool" ; thank you a lot Navin Sir
@pvinoth2146
@pvinoth2146 3 года назад
Hello Sir, Thanks so much for the lessons. I have coded factorial of a number using reduce functions. Its working:-) from functools import reduce s=[] n=int(input("Enter the number")) for i in range(n+1): if i==0: continue else: s.append(i) print(s) total = reduce(lambda a,b: a*b,s) print(total)
@HimanshuVerma-rr2ww
@HimanshuVerma-rr2ww 5 лет назад
So enjoyable your teaching skill. Really i am getting all this things free. Thanks sir great heads off.
@MegaCherry0
@MegaCherry0 4 года назад
Class Moniter could you please let me know whether this channel has videos on python and are they easy to understand? Thanks in advance.
@truthalonetriumphs6572
@truthalonetriumphs6572 4 года назад
"Hats off" is the expression
@SaFFire123x
@SaFFire123x 4 года назад
@@MegaCherry0 This is a reply after 7 months but I can confidently say that this is the best channel for python. I regret not discovering this channel earlier
@MegaCherry0
@MegaCherry0 4 года назад
SaFFire thank you so much buddy.
@SaFFire123x
@SaFFire123x 4 года назад
@@MegaCherry0 you're welcome. I'm 7 months late though 😅
@deepwell8554
@deepwell8554 6 лет назад
You are a teacher of note ... not only a coder ... Thanks for the effort. If I can do anything to help you expand ( other than liking or subscribing ), let me know.
@uchiha_love
@uchiha_love 10 дней назад
I have watched so many tutorials and had no idea until i watch this masterpiece🎉
@kaikobadshamim6118
@kaikobadshamim6118 3 месяца назад
Your teaching technique is so lovely!!!
@rohithjohn959
@rohithjohn959 4 года назад
Sir...your teachings are awesome and you are a blessing to a lot of new programmers
@أبوفاطمة_أبوعبدالله
@أبوفاطمة_أبوعبدالله 3 месяца назад
Your explanation is very awesome. Thanks a lot!!
@vrowmuria
@vrowmuria 6 лет назад
Many many thanks Navin for clearing the concept of Map Reduce. You are a gem. Super likes
@shantabaikanade6075
@shantabaikanade6075 3 года назад
You are really a fabulous teacher 🤩🤩🤩
@ashutoshpatil26
@ashutoshpatil26 6 лет назад
simple and clean Explanation thank you sir
@murodjonsadullaev4674
@murodjonsadullaev4674 4 года назад
I like the way you teach us, Navin. I am learning a lot from your videos. From this video, I learned how to find Factorials of a number with just two lines of code using reduce. from functools import reduce print(reduce(lambda a, b: a * b, range(1, int(input("Enter a number: ")) + 1))) cool bro, really appreciate your help on learning python :)
@yfjsdgzjdnfn
@yfjsdgzjdnfn 2 года назад
Factorial!!!
@huzaifaelnaeem1620
@huzaifaelnaeem1620 5 лет назад
it's brief and clear .Thank you so much sir
@PrasannaKumar-zx7gr
@PrasannaKumar-zx7gr 4 года назад
Than you sir, after working out this problem myself in laptop, this become simple now... You are a greater teacher and thanks for making me to sit here till above 40 video series. Everyday waking up with your videos make my day very active.... Thank you!
@mahalingpreethi1021
@mahalingpreethi1021 2 года назад
Sir, all lambda functions are working similar(filter(),map(),reduce()). Then what is the main difference between them. Among three which function is better to use.
@uvishnuprasad2944
@uvishnuprasad2944 3 года назад
from functools import * num = [2,4,5,6,7,8,9,1,0] odds =(list(filter(lambda n: n%2!=0 ,num))) square=(list(map(lambda a: a*a,odds))) sum=(reduce(lambda x,y: x+y,square)) print(sum)
@vakhariyajay2224
@vakhariyajay2224 2 года назад
Thank you very much. You are a genius.
@WanderEatLearn
@WanderEatLearn 2 года назад
Very helpful to me. It's crystal clear. Prior to watching this video I could not understand filter and map.
@iqbalhonnur4451
@iqbalhonnur4451 2 года назад
Excellent explanation !!!
@lasithdissanayake
@lasithdissanayake 3 года назад
this was the only tutorial I undestood about map filter an reduce
@vanshchauhan2373
@vanshchauhan2373 2 года назад
loved the method of your explaining
@shivakumarreddyp8764
@shivakumarreddyp8764 4 года назад
This is the Beauty of python.... And sir hats off for ur teaching
@meghhanigam8375
@meghhanigam8375 3 года назад
You are the best.... no teacher ca teach like you
@wwmcgregor9031
@wwmcgregor9031 5 лет назад
Navin you are a great teacher!
@mattshubat
@mattshubat 4 года назад
Love how you kept in your mistakes. Very honest.
@prashantbhatade6367
@prashantbhatade6367 Год назад
After watching this video my all doubt got clear hats off to sir quality and method of teaching lit.. Tx
@naveenpolasu4670
@naveenpolasu4670 5 лет назад
Sir, Can you please start Machine learning with Python tutorial.
@beecrofttobiloba1869
@beecrofttobiloba1869 3 месяца назад
Sir this is very necessary
@vivektanwar628
@vivektanwar628 3 месяца назад
perfectly explained thanks,,,was confused earlier
@dipannita7436
@dipannita7436 4 года назад
u makes the concept understandable
@rohanram7197
@rohanram7197 5 лет назад
Navin sir you are a legend 🙏🏻❣️ Thanks again
@italiens9905
@italiens9905 3 года назад
you are awesome teacher ever ... And your teaching style is really energetic
@mohammedumarfarhan9900
@mohammedumarfarhan9900 2 года назад
This man is an absolute legend
@chinmaydas4053
@chinmaydas4053 6 лет назад
Very important video but please sir try to upload more videos daily. After uploading complete series please sir make some projects/softwares.. it will be very helpful to understand the real world problems 🙏🙏🙏..
@asishraz6173
@asishraz6173 4 года назад
After a long time, I finally understood the concept of Lambda, Reduce, Map function. Great video and well explained. Thank you so much sir. Now eager to learn more and more every day through your videos. Thank you so much, keep up the great work.
@cnx_1441
@cnx_1441 3 года назад
I thought your vids were useless at the first but then I understood that your vids r very helpful thank you soo much.
@jaheerkalanthar816
@jaheerkalanthar816 4 года назад
sir , U r my hero shall i tell in my mother toungue, Marana mass
@allofmystuffs
@allofmystuffs 4 года назад
Sorry to ask. Which language.?
@iloveyou-gk7cw
@iloveyou-gk7cw 4 года назад
@@allofmystuffs tamil
@rehithkrishna543
@rehithkrishna543 4 года назад
Thalaivar 🔥
@venupunna9940
@venupunna9940 3 года назад
Great tutorial and by the way THANKYOU for making these videos AD FREE.
@054_ritesh3
@054_ritesh3 4 года назад
The next level of awesome teaching
@shreyaswinividhyadhare9228
@shreyaswinividhyadhare9228 4 года назад
Sir your class is fantastic, more understandable
@dreamphoenix
@dreamphoenix Год назад
Excellent teaching. Thank you.
@easydatascience2508
@easydatascience2508 Год назад
You can see mine too. Hope the Python playlist, step by step sequentially arranged by sections, will be valuable. Source files can be found in the description of the each video. There is another playlist , R beginning course in the channel too.
@oliviayeo5753
@oliviayeo5753 5 лет назад
LAMBDA 4:03 LMAO Thank you for the tutorial!
@memeea6484
@memeea6484 Год назад
Thank you so much the only tutorial that i can actually understand!! ♥♥
@pareshdandane
@pareshdandane 6 лет назад
I saw you video after 2 months and editing level is whole different level. I got so much inspiration from you. thank you sir for making this video!!
@b.sasikumar2141
@b.sasikumar2141 4 года назад
I like the way of u teaching sir superb...... 👌👌
@Think_differently955
@Think_differently955 5 лет назад
Great Playlist for Python. I like it. One doubt here, how a+b added all variables without using any loop?
@mohitsharma4667
@mohitsharma4667 4 года назад
if we have the list abc = [1,2,3,4] it will take the first two elements from the list and perform the function, the new list now becomes [3,3,4] the process is repeated till we have a single value
@sidskywalker8423
@sidskywalker8423 4 года назад
@@mohitsharma4667 for e.g , l = [2, 4, 6, 8] >>> reduce(add_all, l) 2 + 4 --> 6 6(2 + 4) + 6 --> 12 12(6 + 6) + 8 --> 20 final sum: 20 that's how reduce() works! :)
@rituhalder835
@rituhalder835 8 месяцев назад
wowww!! beautifully explained!!
@muhammadsultanularafin8846
@muhammadsultanularafin8846 4 года назад
Wonderfully explained! Thanks.
@fhdhejeh63
@fhdhejeh63 5 лет назад
you are helping many people sir. keep going
@ruwindarowel8200
@ruwindarowel8200 2 года назад
Hands down the best place to learn Python❤❤❤❤❤❤
@abhaykanwasi881
@abhaykanwasi881 2 года назад
Big Data concept is so relatable for me to understand this concept.❤❤
@dineshr3841
@dineshr3841 3 года назад
Really awesome explanation about this topic, I really love it and understood very well by ur way of teaching...🙏❤️
@ashishgaur862
@ashishgaur862 6 лет назад
Awesome work sir and please make more videos like these and give us some projects and assignment 👍🏻💯
@jitendrasharma4
@jitendrasharma4 4 года назад
Very Nice explanation , Thank you
@harshwardhansingh617
@harshwardhansingh617 3 года назад
he said that these functions are not easy, but I found them so easy : P
@deepthireddy4036
@deepthireddy4036 Год назад
I really like the way you explain concepts❤
@ShaikFarhanaFarhana-kw3kw
@ShaikFarhanaFarhana-kw3kw 3 месяца назад
Super explanation sir
@vidhikumawat5876
@vidhikumawat5876 4 года назад
Navin sir thank you soo much for this series...I learned alot from this series...it is very easy and helpful..thank you soo much for your efforts ☺️☺️
@chaithalikshetty480
@chaithalikshetty480 2 года назад
Sir all I can say is your perfect..
@lightningspeed6466
@lightningspeed6466 4 года назад
This was very helpful
@milankbudha
@milankbudha 4 года назад
thank you sir for explaining so easily...
@inganzamarumpu
@inganzamarumpu 4 года назад
all things are clear but i really like comprehensions
@voalcalisticTanmay
@voalcalisticTanmay 6 лет назад
I have made a use of lambda and map() method and would like to share .. And here is the snippet : a,b=[int(x) for x in input("Enter two values seperated with spaces : ").split()] tup=( lambda c,d : c+d, lambda c,d : c-d , lambda c,d : c*d , (lambda c,d : (c+d)/2)) dic=dict(zip(('Sum' , 'Difference' , 'Product' , 'Average'),map(lambda x : x(a,b),tup))) for j in dic: print("{} : {}".format(j,dic[j])) Hope this gets useful in some way. Thank You :)
@dadmehrtatality1144
@dadmehrtatality1144 4 года назад
Hey man tnx for your help I was really confused but now I find it out !!😍
@ngharish
@ngharish 3 года назад
i knew lamda function but filter ,map and reduce is useful for handling huge data ... so thanks for video
@NabhPal17
@NabhPal17 Год назад
धन्यवाद Sir जी।
@sufiyanmogal1527
@sufiyanmogal1527 2 года назад
Sir please start with python on these weekend it will help those people who are watching your python playlist
@pranaymane23
@pranaymane23 4 года назад
Find average of list: from functools import reduce list = [1,2,3,4,5,6,7,8] ave = reduce(lambda a,b: a+b,list)/len(list) print(ave)
@renukadasari4670
@renukadasari4670 2 месяца назад
it's 2024 still we are following your videos even though its 5 years ago B'coz of your excellent explanation and amazing programming
@hetpatel7918
@hetpatel7918 3 года назад
great presentation skills sir
@sufiyanmogal1527
@sufiyanmogal1527 2 года назад
Nice Explanation sir
@aakashmehta7336
@aakashmehta7336 4 года назад
Hi Navin. Your videos are amazing. I am following your python series. I wanted to know from where did you learn the big data? I saw you said that you have learnt big data. Could you you please let me know the reference please? I want to learn big data.
@saikrishnavadali05
@saikrishnavadali05 3 года назад
Awesome video!!
@tamaladhikari7950
@tamaladhikari7950 8 месяцев назад
Comparaing it with java in java we have to use -> operator here only : and also here we have to write lambda
@a.rhithesh7711
@a.rhithesh7711 4 года назад
navin sir i am very happy for your lectures, its very clear cut and good ...a request form my side to plan videos on problem solving python, which is used for placements for some lakhs of engineering students...i am expecting that one.
@Rohitkumar-tx6jl
@Rohitkumar-tx6jl 3 года назад
One of the best
@webcreationstudio7088
@webcreationstudio7088 3 года назад
code --> from functools import reduce def adding(a,b): return a+b def update(n): return n*2 num=[1,2,3,4,5,6,7,8,9,10] even=list(filter(lambda x:x%2==0,num)) print(f"even numbers are {even}") double=list(map(lambda x:x*2,even)) print(f"double of all the even numbers {double}") sum=reduce(lambda x,y:x+y,double) sum=str(sum).center(10) print(f"the addition of all the numbers ae present in the double are {sum}")
@pritvips
@pritvips 5 лет назад
thanks for the videos sir....hats off to your teaching talent
@network_noob
@network_noob 3 года назад
Thank you so much!
@theharshkhar3
@theharshkhar3 5 месяцев назад
Good work bro!
@oussamaelbaz7675
@oussamaelbaz7675 3 года назад
Thank you.
@tigrayrimey6418
@tigrayrimey6418 3 года назад
Great lecture!
@amitroy-kh1wn
@amitroy-kh1wn 5 лет назад
Sir, How can you describe so easily and understandably. Hats off Sir
Далее
#44 Python Tutorial for Beginners | Decorators
7:33
Просмотров 604 тыс.
Провал со стеклянным хлебом…
00:41
Python: Lambda, Map, Filter, Reduce Functions
9:59
Просмотров 382 тыс.
#49 Python Tutorial for Beginners | Class and Object
11:01
Python Lambda Functions??
4:30
Просмотров 186 тыс.
#45 Python Tutorial for Beginners | Modules
7:20
Просмотров 624 тыс.
Python's Map Function Explained..
3:02
Просмотров 140 тыс.
Python higher order functions 👑
6:28
Просмотров 37 тыс.
Проверил, как вам?
1:01
Просмотров 2,7 млн
Mac USB
0:59
Просмотров 26 млн