Комментарии:
Thanks!!!
ОтветитьDifference between itemgetter and attrgetter ?
ОтветитьAfter extensive looking for sort method of larger lists of dictionaries, this is the very best!
ОтветитьBig thumbs up. Was super-helpful and did the operation exactly as I needed it for my use case.
ОтветитьVery nice video! Helped me a lot.
ОтветитьHow to sort the list in the alphabetic order when the age for more than one entry is same???
ОтветитьDo you have and idea a third way to sort a list of dicts by a group of keys. I figure out using sort, lambda dictionary and itemgetter. Its an exercise of my studies that i cant figure out!
ОтветитьHow can u use keys index number instead of name? Do u just put 0,1 etc inside the
parentheses after itemgettr?
I've been trying to solve this problem for a whole day... Thank you so much! Straight to the point and well produced, subscribed and I hope to see more videos like these :)
ОтветитьThank you very much. This video is nice. :)
ОтветитьHelpful video. Please how can you add another record (dictionary) to the one above
For instance what will be the function to add
{'name' : 'Pretty', 'join_date' : '2020--03-03', 'age' : 23 }
How can one add this dictionary to the users above
Thank you for your sharing =)
ОтветитьHelped me with a problem i could not figure out. Thank you!
Ответитьi hv a column of lists. And those hv nested dictionaries inside the list. . How to extract all keys in separate columns?
Ответитьlen(subscribers) += 1
ОтветитьSiq ty
ОтветитьHow to update list of dictionary on specific index
Ответитьthanks allot 🙂
ОтветитьCould you show us how to deploy a flask app with docker on windows in LAN? Thanks
ОтветитьStill waiting for flask socket io heroku toturial :)
ОтветитьGreat video. I needed that utility recently and could have not make it. I've also noticed a huge improvement in terms of content flow and explanation. Good job!
ОтветитьSomething to keep in mind: when you work with large lists of dicts(~1Mil) itemgetter slows things down abit. Therefore I use lambda magic...
sorted(users, key=lambda k: k['name'])
I use this almost every day ... It's very efficient.
If you find yourself doing such sorts quite a bit, I've written a library called "PLOD" that is available on PyPI. it's strength, in part, is that it handles edge cases well, such as missing keys and the like. You can so something like:
newlist = PLOD(oldlist).sort('name', none_greater=True, reverse=True).returnList(limit=10)
That creates a new list sorted by 'name' in reverse but where missing names are put on top. Programmers interested in adding to the open source library are welcome :).
Also we can use many fields with itemgetter('join_date','age',....). Here is a question: In SQL notation we use different order like this: "order by join_date asc,age desc". What about Python's list sorting?
ОтветитьAre you also the creator of the nodejs master class?
Ответить