Python filter 🍺

preview_player
Показать описание
Python filter function tutorial example explained

#python #filter #function

# filter() = creates a collection of elements from an iterable,
# for which a function returns true
#
# filter(function, iterable)

Bro Code merch store 👟 :
===========================================================
===========================================================
Рекомендации по теме
Комментарии
Автор

# filter() = creates a collection of elements from an iterable,
# for which a function returns true
#
# filter(function, iterable)

friends = [("Rachel", 19),
("Monica", 18),
("Phoebe", 17),
("Joey", 16),
("Chandler", 21),
("Ross", 20)]

age = lambda data:data[1] >= 18

drinking_buddies = list(filter(age, friends))

for i in drinking_buddies:
print(i)

BroCodez
Автор

0:39
you should have said, "i just made up some friends for all of these ages"

oximas-oevf
Автор

Good work Bro!

And in this video, the lambda function is starting to make more sense to me now

Also I somehow managed to make connection of the list of tuples in this example to the DataFrame that I used to filter / sort in pandas, which helped me grasp what you are teaching a lot better

loveSG
Автор

hey bro hello from nicaragua been learning with your course I just wanna say youre the best

marcelobarahona
Автор

Bro, This is a very fantastic tool,
Look at Line 7 how nicely it's done, I understood how layering works in Python better after coding

cars = (("Car_1", "Ford", 2022),
("Car_2", "Toyota", 2021),
("Car_3", "Ford", 2023),
("Car_4", "Honda", 2020),
("Car_5", "Ford", 2022))

filter_company = lambda car: car[1] == "Ford"
filtered_cars = list(filter(filter_company, cars))
filter_year = lambda car: car[2] >= 2022
for car in filter(filter_year, filtered_cars):
print(car)

AIFutureCast
Автор

Finally i understand lambda a bit better now (⌐■_■)

Amir_Plays_non_stop
Автор

Hi Bro
In last video you used:
to_euros = lambda data: (data[0], data[1]*0.82)

On this one you used:
age = lambda data:data[1] >= 18

Despite you don't call data[0] as part of the lambda it is still printed ... how come???


thanks

JoseHernandez-qkby
Автор

I have a doubt in map function if I only pass data[1] it only prints value(prices in your map video but not items) but here in filter function why data[1] returns both name and age...?

krishnaanurag
Автор

who is seeing this after mathew perry died

pranavsingh
Автор

0:39, not accurate proggrammers don't have friends

oximas-oevf