Комментарии:
if you lazy thinking the list is long, take this :
my_groceries = ['apple', 'banana', 'banana', 'orange', 'banana', 'apple', 'beet', 'carrot', 'ginger', 'kale', 'ginger', 'ginger', 'ginger', 'kale', 'ginger']
Awesome!!!
ОтветитьYou are best
ОтветитьHow does this work with a 3d list?
ОтветитьIn the case of object(string) type pandas.series, .value_counts() would do the same but it gives out a dataframe which respect to each class within the category but this will save a lot of time. Thanks Qazi :D
ОтветитьCan I register to your platform when I have the money.
ОтветитьHow to determine how much time just a particular word is used in a sentence, if I don't want to know the times for all of the words used in a whole sentence.. Please help me out for that!
ОтветитьWhich software is best for beginer to learn python ?
ОтветитьNice one qazi
ОтветитьThanks to qazi I now know how to hack the us goverment
ОтветитьTHIS IS WHAT I DID.
my_groceries = ['apple', 'banana', 'banana', 'orange', 'banana', 'apple', 'beet', 'carrot', 'ginger', 'kale', 'ginger', 'ginger', 'kale', 'ginger']
Final_List = []
DICT = {}
x=0
for element in my_groceries:
if element in DICT:
DICT[element]+=1
else:
DICT[element]=1
for item in DICT:
Final_List.append((item,DICT[item]))
while x<len(Final_List):
for product in range(0,len(Final_List)-1):
if Final_List[product][1] > Final_List[product+1][1]:
pass
else:
temp = Final_List[product]
Final_List[product] = Final_List[product+1]
Final_List[product+1] = temp
x += 1
print(Final_List)
Thank you !!
Ответитьhi kazi i am from algeria and i started learning python but i am not sure that i can find a job here in algeria so can i work from here as a freelancer or should i just quite learning it to not waste the time answer me please
ОтветитьNot in descending order, but pretty close to the requirements (in alphabetical order, with less code :-P ).
my_groceries = ['apple', 'banana', 'banana', 'orange', 'banana', 'apple', 'beet', 'carrot', 'ginger', 'kale', 'ginger', 'ginger', 'kale', 'ginger']
First pass:
print('[' + ' '.join(sorted(map('(\'%s\', %d), '.__mod__, Counter(map(str.lower, map(str.strip, my_groceries))).items()))) +']')
Result: [('apple', 2), ('banana', 3), ('beet', 1), ('carrot', 1), ('ginger', 4), ('kale', 2), ('orange', 1) ]
Comparison to your code:
from collections import Counter
counter_thingy = Counter(my_groceries)
print(counter_thingy.most_common())
Result: [('ginger', 4), ('banana', 3), ('apple', 2), ('kale', 2), ('orange', 1), ('beet', 1), ('carrot', 1)]
Brother you make programming look easy and fun. Your channel helped me a lot to learn python. Thank you.
Ответитьawesome!
ОтветитьWow, that was an easy trick that I didn't know;instead of writing while loop and add them.
This is really helpful. Thank you
Hey qazi, I am not able to find idle for windows and I don't know to use pycharm.
ОтветитьYo I really like this series.
ОтветитьThanks! That was helpful
ОтветитьNice...!
ОтветитьThanks!
ОтветитьThanks bro
ОтветитьAmazing...
ОтветитьAfter long time a video I know your bzy your with profitable program Good luck
ОтветитьQazi !
Miss you ,bro .
I would suggest the name of this series is (Python Explorer)
ОтветитьGood to see u back man
ОтветитьQazi you know how to teach!
Ответить5th😊
ОтветитьFirst
Ответить