Advanced Dictionaries: defaultdict in Python

Поделиться
HTML-код
  • Опубликовано: 21 сен 2024
  • Today we learn about defaultdict and advanced dictionaries in Python.
    ◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾
    📚 Programming Books & Merch 📚
    🐍 The Python Bible Book: www.neuralnine...
    💻 The Algorithm Bible Book: www.neuralnine...
    👕 Programming Merch: www.neuralnine...
    🌐 Social Media & Contact 🌐
    📱 Website: www.neuralnine...
    📷 Instagram: / neuralnine
    🐦 Twitter: / neuralnine
    🤵 LinkedIn: / neuralnine
    📁 GitHub: github.com/Neu...
    🎙 Discord: / discord

Комментарии • 38

  • @Radical9535
    @Radical9535 Год назад +5

    I learned how to use default dictionaries! thanks for these videos again super useful! please don't stop making content!

  • @jasonchien5359
    @jasonchien5359 4 месяца назад

    Amazing video regarding the usage of defaultdict, learnt a lot and I see the benefits over the default dictionary compare to defaultdict class.
    Keep up the good work 👍👍👍

  • @Лена-в1н6ы
    @Лена-в1н6ы 10 месяцев назад

    This is my first comment in English on utube. I liked your videos, this and others, they are all very interesting and useful. Thank you very much!

  • @kvelez
    @kvelez 10 месяцев назад +1

    from collections import defaultdict
    words = ["apple", "banana", "carrot", "avocado", "brocoli"]
    grouped_words = {defaultdict(list)}
    for word in words:
    grouped_words[word[0]].append(word)
    print(grouped_words)

  • @ВладФоменко-р4е
    @ВладФоменко-р4е Год назад +2

    I just recently run into this defaultdict in my colleague's code, and now you share what it's all about. How's that work?)) Thank you for a great tutorial.

  • @blendercharacter5418
    @blendercharacter5418 10 месяцев назад

    this is so usful for me right now! Im glad that I found this I'll use it tommorrow ! thank you!

  • @SolidBuildersInc
    @SolidBuildersInc Год назад

    This was a Game Changer on Dictionaries for me.
    I will read the docs....🎉

  • @JoseAntonio-jf5lz
    @JoseAntonio-jf5lz Год назад +1

    Excellent explanation, thank you very much.

  • @aflous
    @aflous Год назад +2

    @11:44 you still can have some logic using a callable, no need to inherit from defaultdict

  • @kvelez
    @kvelez 10 месяцев назад

    from collections import defaultdict
    my_list = [1,2,3,44,56,6,65]
    counter = defaultdict(int)
    values = {
    0: "person0",
    1: "person1",
    2: "person2",
    3: "person3",
    }
    for item in my_list:
    counter[item] += 1
    print(counter)

  • @pranee31
    @pranee31 Год назад +1

    Please make a video on "how to use OrderedDict in defaultdict"." defaultdict(lambda: OrderedDict())" how this works?

  • @kvelez
    @kvelez 10 месяцев назад

    from collections import defaultdict
    class DefaultDicts(defaultdict):
    def __missing__(self, key):
    self[key] = value = len(key)
    return value
    test = DefaultDicts()
    print(test["hello"])
    print(test["hi"])
    print(test)

  • @kvelez
    @kvelez 10 месяцев назад

    from collections import defaultdict
    tuple_list = [("A",10),("B",4),("A",5),("C",7),("B",1)]
    grouped_data = defaultdict(list)
    for k,v in tuple_list:
    grouped_data[k].append(v)
    print(grouped_data)
    grouped_data = {k:sum(v) for k, v in grouped_data.items()}
    print(grouped_data)

  • @kvelez
    @kvelez 10 месяцев назад

    from collections import defaultdict
    lambda_dict = defaultdict(lambda: "hello world")
    print(lambda_dict["hello"])

  • @lxathu
    @lxathu Год назад

    Thanks.
    Being spoiled by awk and perl, I thought about having this a couple of times

  • @turtlecode
    @turtlecode 4 месяца назад

    Perfect tutorial!

  • @alexanderkaess9505
    @alexanderkaess9505 Год назад

    Very good explanation

  • @paulthomas1052
    @paulthomas1052 Год назад

    Thanks - very interesting tutorial.

  • @pawelantczak6476
    @pawelantczak6476 Год назад

    Is default dict. quicker/better vs standard_dict[new_key]=standard_dict.get(new_key,0)+current_value?

  • @kiorde
    @kiorde Год назад

    Very useful, thanks!

  • @BioLife_Hacks
    @BioLife_Hacks 10 месяцев назад

    thanks a lot, this vid is really useful👌

  • @ayoife3482
    @ayoife3482 Год назад +3

    Is it just me or is the audio volume low? 🤔

  • @ayonnnnnnn
    @ayonnnnnnn Месяц назад

    tyyyyyyy

  • @tehyonglip9203
    @tehyonglip9203 9 месяцев назад

    although defaultdict is less general compared to the regular dict, I think it's more useful and more powerful than the regular one. it's a shame how underused this function is.

  • @harsharya828
    @harsharya828 Год назад

    Please Make Video on Complex Data Type in python.

  • @julianreichelt1719
    @julianreichelt1719 Год назад

    very nice

  • @maevwat
    @maevwat Год назад +3

    damn, bot infestation in the comments

  • @ahmehhhd
    @ahmehhhd Год назад

    niceee

  • @philtoa334
    @philtoa334 Год назад

    Thx_.

  • @harsharya828
    @harsharya828 Год назад

    Amazing Video 🔥🔥🔥

  • @tsunningwah3471
    @tsunningwah3471 Год назад

    bilibli

  • @Nima-f5e
    @Nima-f5e 7 месяцев назад

    AAA

  • @ayoife3482
    @ayoife3482 Год назад

    Is it just me or is the audio volume low? 🤔

    • @moon911x
      @moon911x Год назад

      volume low i think