I researched about lambda functions but was still confused on how it was being used in the sort and sorted functions. You covered it thankfully in this video, and it helped a lot, thanks!
don't take me wrong this channel is great and I learn a lot from him , but the best ( hands down ) goes to Bro Code 12 hour python tutorial , it's unbelievable And I just want to share with everyone
from functools import reduce add_num = lambda x: x+10 #anonymous print(add_num(5)) mul_num = lambda x,y: x*y print(mul_num(5,4)) points2D = [(1,2), (15,1), (5,-1), (10,4)] sort_points = sorted(points2D) #sort by x argument print(sort_points) sort_points = sorted(points2D, key=lambda x: x[1]) #lambda sort with y print(sort_points) sort_points = sorted(points2D, key=lambda x: x[0]+x[1]) #lambda sort sum print(sort_points) a = [1,2,3,4] b = list(map(lambda x: x*2, a)) #map iterable and lambda func + arr print(b) print([x*2 for x in a]) #list comprehension abbreviation c = list(filter(lambda x: x % 2 == 0, a)) #filter -> bool + lambda + arr print(c) print([x for x in a if x % 2 == 0]) #list comprehension d = reduce(lambda x,y: x*y, a) #product of list print(d)
I remember when I wanted to put an if in a lambda function and it wasnt working and i was losing hair. Then i realized that the else is *required* otherwise itll throw an error, unlike in a list comprehension where an else is not required I still mostly only stick to using list comprehensions although I do love the way the code aesthetically looks in a lambda function haha
according to pep 8 we should not assign the lambda functions and use them as call backs , and when we want to name it use just def mul(x,y):return x*y is one liner and is fine , he only use case I saw somewhere was to assign it in a call back via walrus operator that was some application inside the function too
Good content but lack clarity of what you want to achieve with each method. Especially when starting writing example it is not clear what you want to achieve which minimizes the value of content
Thanks for all your helpful videos. That would be great if you share the configuration of your VS code. It looks as simple as sublime, and you don't necessarily run your codes in terminal.
Change the name for this video series. This is beginner stuff. Don't lie to people by calling it advanced. You lose your credibility from the start when you LIE to people right from the start.
I researched about lambda functions but was still confused on how it was being used in the sort and sorted functions.
You covered it thankfully in this video, and it helped a lot, thanks!
I had thought that the key parameter was a value not a function. But again, it was a huge help and very easy to understand
Probably the best python tutorial in YT.
thanks a lot!
don't take me wrong this channel is great and I learn a lot from him , but the best ( hands down ) goes to Bro Code 12 hour python tutorial , it's unbelievable And I just want to share with everyone
Best advanced python tutorial
Really well presented; you conveyed the concepts extremely well.
glad to hear this :)
Thanks for the vid Patrick! This really helped me
This is the best python tutorial i think. Thanks for giving free advance tutorial.
Not quite an advanced course but extremely thorough and brilliantly presented. I've saved it so I can keep it as a reference.
Thank you very much! I know it’s more between beginner and advanced, but I’m glad you like it :)
Thank you for making things simple to understand
Thank you! I needed a video on how to use these, as the docs didn’t make a whole lot of sense on my first read through. This has helped out a lot!
I found this Video the best, how is this Video dont have more likes and Views.
thanks a lot!
from functools import reduce
add_num = lambda x: x+10 #anonymous
print(add_num(5))
mul_num = lambda x,y: x*y
print(mul_num(5,4))
points2D = [(1,2), (15,1), (5,-1), (10,4)]
sort_points = sorted(points2D) #sort by x argument
print(sort_points)
sort_points = sorted(points2D, key=lambda x: x[1]) #lambda sort with y
print(sort_points)
sort_points = sorted(points2D, key=lambda x: x[0]+x[1]) #lambda sort sum
print(sort_points)
a = [1,2,3,4]
b = list(map(lambda x: x*2, a)) #map iterable and lambda func + arr
print(b)
print([x*2 for x in a]) #list comprehension abbreviation
c = list(filter(lambda x: x % 2 == 0, a)) #filter -> bool + lambda + arr
print(c)
print([x for x in a if x % 2 == 0]) #list comprehension
d = reduce(lambda x,y: x*y, a) #product of list
print(d)
THANK YOUUUUUUU IT WEAS SO CLEAR AND VERY HELPFUL!!
Thanks for making life easier!
Nice, thanks
Nice and neat
Hey Pal you deserve more than a million subs... dude u helped me a lot in the * operator video
Thanks for the feedback :)
I would loved it more if you've covered the if and else inside lambda. But thank you for your efforts!
I remember when I wanted to put an if in a lambda function and it wasnt working and i was losing hair. Then i realized that the else is *required* otherwise itll throw an error, unlike in a list comprehension where an else is not required
I still mostly only stick to using list comprehensions although I do love the way the code aesthetically looks in a lambda function haha
@@CrazyFanaticMan you can put an else in a list comprehension
@@gabrielafotey5069 Yes you can but it isn't necessary
In a lambda function, an else is necessary if you want to use an if statement
@@CrazyFanaticMan I get you now. I thought you said else isn’t allowed in list comprehensions. My bad
Thanks but i wish you addressed using lamda on a dataframe with apply and map. Getting the syntax right can be frustrating for newbies.
Thanks for the feedback! Will consider this next time
useful and clear tutorial, thanks
Nice video bro.
Thanks for the explanation.
according to pep 8 we should not assign the lambda functions and use them as call backs , and when we want to name it use just def mul(x,y):return x*y is one liner and is fine , he only use case I saw somewhere was to assign it in a call back via walrus operator that was some application inside the function too
great
Thank you it was helpful 👍
thanks! glad it's helpful
thanks
It is possible to use Lambda with strings?
great work!
Thanks!
Thank you! Its so understandable!
Good content but lack clarity of what you want to achieve with each method. Especially when starting writing example it is not clear what you want to achieve which minimizes the value of content
would love to see more on the groupby function in the future. Other than that great video as always :)
lambda or list comprehension ftw?
The X We call it parameter or argument !
Thanks for all your helpful videos. That would be great if you share the configuration of your VS code. It looks as simple as sublime, and you don't necessarily run your codes in terminal.
Hi, I use pretty much the standard configuration. The only extensions I have installed are: Python, Code Runner, and pylint
yes you can change the setting of code runner extension.
and can run your code in output.
Hard to see a situation why reduce() is useful. Any suggestion?
Hey could you please maximise screen
cool!
Is this pycharm ?
Or something, plz say so I can also download
I'm 99% sure this IDE he's using is VS Code for Mac, not PyCharm...
Can I know what editor you are using? Thanks~
pretty sure it's Visual Studio Code
❤
i'm gonna sleep....dude
Change the name for this video series. This is beginner stuff. Don't
lie to people by calling it advanced. You lose your credibility from
the start when you LIE to people right from the start.
Boring