How To Create A Word Cloud In Python | Tutorial [EASY] 💻

Поделиться
HTML-код
  • Опубликовано: 8 фев 2025
  • 👉 Explore All My Excel Solutions: pythonandvba.c...
    𝗗𝗘𝗦𝗖𝗥𝗜𝗣𝗧𝗜𝗢𝗡
    ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
    In this tutorial, I will show you, how to create a Word Cloud in Python by using the library called “wordcloud”.
    👉 Link to wordcloud library documentation:
    amueller.githu...
    Get the code & excel file from GitHub:
    github.com/Sve...
    𝗧𝗢𝗢𝗟𝗦 𝗔𝗡𝗗 𝗥𝗘𝗦𝗢𝗨𝗥𝗖𝗘𝗦
    ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
    🆓【𝗙𝗥𝗘𝗘】Excel Add-in (𝗠𝘆𝗧𝗼𝗼𝗹𝗕𝗲𝗹𝘁): pythonandvba.c...
    📊 Dashboard Excel Add-In (𝗚𝗿𝗮𝗳𝗹𝘆): pythonandvba.c...
    🎨 Cartoon Charts Excel Add-In (𝗖𝘂𝘁𝗲𝗣𝗹𝗼𝘁𝘀): pythonandvba.c...
    🤪 Fun Emoji Excel Add-In (𝗘𝗺𝗼𝗷𝗶𝗳𝘆): pythonandvba.c...
    📑 Excel Templates: pythonandvba.c...
    🎓 My Courses: pythonandvba.c...
    📚 Books, Tools, and More: pythonandvba.c...
    𝗖𝗢𝗡𝗡𝗘𝗖𝗧 𝗪𝗜𝗧𝗛 𝗠𝗘
    ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
    🔗 LinkedIn: / sven-bosau
    📸 Instagram: / codingisfun_official
    💻 GitHub: github.com/Sve...
    💬 Discord: pythonandvba.c...
    📬 Contact: pythonandvba.c...
    ☕ 𝗕𝘂𝘆 𝗺𝗲 𝗮 𝗰𝗼𝗳𝗳𝗲𝗲?
    If you want to support this channel, you can buy me a coffee here: pythonandvba.c...

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

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

    Very Easy Excellent way of getting the Word Cloud , thanks much from India , Bengaluru

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

      Glad you liked it! Greetings to Bengaluru! :)

  • @jonasvw
    @jonasvw 4 года назад +1

    Thanks for this short tutorial! :)

  • @CaribouDataScience
    @CaribouDataScience 2 года назад

    Thanks, that was easy!

    • @CodingIsFun
      @CodingIsFun  2 года назад

      Glad you liked it. Thanks for watching.

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

    Excelente tutorial! Muchísimas gracias!

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

      Glad you liked it. Thanks for watching. Cheers, Sven ✌️

  • @OscarHernandez-ul5go
    @OscarHernandez-ul5go 3 года назад

    Thank you very much for your tutorials, they are very helpful, greetings from mexico

    • @CodingIsFun
      @CodingIsFun  3 года назад +2

      Thank you Oscar Hernández, I'm happy to hear that you've been finding the videos useful. Thanks for taking the time to leave a comment and for watching! Greeting to Mexico :)

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

    Great tutorial ! Thanks very much !!!!

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

      Thanks for watching! Glad it was helpful! :)

  • @lsborba1
    @lsborba1 2 года назад

    Quite useful!! Congrats!!

  • @queencarolas
    @queencarolas 2 года назад

    Thank you! =) Great tutorial.

    • @CodingIsFun
      @CodingIsFun  2 года назад +1

      Glad you liked it. Thanks for watching! :)

  • @PratapO7O1
    @PratapO7O1 3 года назад

    Thank you this was helpful

    • @CodingIsFun
      @CodingIsFun  3 года назад

      A pleasure! Thanks for watching the video :)

  • @artistheanswer
    @artistheanswer 3 года назад

    that's cool. many thanks!

    • @CodingIsFun
      @CodingIsFun  3 года назад

      Thanks! Glad you liked it :)

  • @NambarameyDy-BRR
    @NambarameyDy-BRR 10 месяцев назад

    it didn't work for me in command prompt. what software do I first need for Windows?

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

      Thanks for watching. You need to have Python installed on your machine. Cheers, Sven ✌️

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

    I have the word cloud down, but I am attempting to do a list of names and wish for the first and last names to stay by each other even though there is a space, is that possible?

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

      Thanks for watching. One possible solution I could think of is the following:
      from pathlib import Path
      import matplotlib.pyplot as plt
      from wordcloud import STOPWORDS, WordCloud
      TXT_FILE = Path.cwd() / "jeff_bezos_speech.txt"
      # Read text
      text = open(TXT_FILE, mode="r", encoding="utf-8").read()
      # List of names (modify this with the names you are looking for)
      names = ['Jeff Bezos', 'Elon Musk', 'Bill Gates']
      # Replace spaces in names with underscores
      for name in names:
      text = text.replace(name, name.replace(' ', '_'))
      stopwords = STOPWORDS
      wc = WordCloud(background_color="white", stopwords=stopwords, height=600, width=400)
      wc.generate(text)
      # store to file
      wc.to_file("wordcloud_output.png")
      I hope it helps!

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

      @@CodingIsFun thank you! is it possible for a wordcloud to use multiple fonts, like the words have a randomized chance on which font they use?

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

      @@maxparsons9431 Your requirements are well noted. Yet, I receive many requests for creating individual solutions. As much as I want to help, I simply do not find the time in my daily schedule to develop & test all the different requests. I hope you can understand. Thank you!

  • @sarvarbek8142
    @sarvarbek8142 4 года назад +1

    which compiler are you using?

    • @CodingIsFun
      @CodingIsFun  4 года назад

      I am not quite sure if I understand your questions correctly, but the Library 'Wordcloud' depends on Matplotlib to generate & export the image.

    • @sarvarbek8142
      @sarvarbek8142 4 года назад

      @@CodingIsFun Oh, sorry for the wrong question. I am just using my command prompt and can not run the script. So I thought maybe it is because of the compiler or translator.
      compiler says:
      Traceback (most recent call last):
      File "C:\Users\sarvar\Desktop\Wordcloud_Tutorial\wordcloud_example.py", line 2, in
      from wordcloud import WordCloud, STOPWORDS
      ModuleNotFoundError: No module named 'wordcloud'

    • @CodingIsFun
      @CodingIsFun  4 года назад

      @@sarvarbek8142 Could you kindly check if you have installed the required libraries (0:28 min)? It looks like, that you do not have 'wordcloud' installed.
      If you still get an error, please let me know.
      Cheers,
      Sven

  • @KanhaiyaLal-ze3ri
    @KanhaiyaLal-ze3ri 2 года назад

    Hi Coding fun, when i am chaging my extention name of my txt file to py it is not convering as you. could you explain it in another video. Thanks

    • @CodingIsFun
      @CodingIsFun  2 года назад

      To convert a .txt file to a .py file, you need to:
      Open the .txt file in a text editor such as Notepad or Sublime Text.
      Write or copy Python code into the file.
      Save the file with a .py file extension.

    • @KanhaiyaLal-ze3ri
      @KanhaiyaLal-ze3ri 2 года назад

      @@CodingIsFun Thanks for replying me i will try my best.

  • @bunnybaghi9989
    @bunnybaghi9989 3 года назад +4

    I was unable to install wordcloud in visual studio code please help me sir

    • @CodingIsFun
      @CodingIsFun  3 года назад +1

      What kind of error message did you get?

    • @bunnybaghi9989
      @bunnybaghi9989 3 года назад

      @@CodingIsFun " unable to find wheel "

    • @CodingIsFun
      @CodingIsFun  3 года назад +1

      @@bunnybaghi9989 Could you please try the following:
      1) Download the .whl file compatible with your Python version and your windows distribution (32bit or 64bit) from here: www.lfd.uci.edu/~gohlke/pythonlibs/#wordcloud
      2) cd to the file path
      3) Run this command python -m pip install
      OR, If you are using Anaconda, please enter the following in the Anaconda Prompt:
      conda install -c conda.anaconda.org/conda-forge wordcloud
      Hope it helps 🙏

  • @Sancarlo76
    @Sancarlo76 2 года назад

    Hi, noob question, why do you have to import the same packages two times?
    Thanks!

    • @CodingIsFun
      @CodingIsFun  2 года назад

      Thanks for watching. Within the wordcloud module, I am importing the WordCloud class. You could also import all classes using "import wordcloud", then you could write:
      wc = wordcloud.WordCloud(background_color="white", stopwords=stopwords, height=600, width=400)
      I hope it helps!

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

    All videos are very helpful..🙏 Thanks for your effort sir.. But how can i make wordcloud in different shapes??

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

      Thanks for watching. Please check out the docs. Here is one example: amueller.github.io/word_cloud/auto_examples/frequency.html#sphx-glr-auto-examples-frequency-py

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

      @@CodingIsFun Done... 👍 Thnks for ur reply

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

    Hi, can you teach how to generate wordcloud but using Trigram?

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

      Thanks for watching and your suggestion.

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

    I'm having an error when installing wordcloud. It says, "this is an issue with the package mentioned above, not pip".

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

      Thanks for watching. Hard to tell from a distance why you are facing an error. Sorry, that I cannot help.

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

      @@CodingIsFun thanks anyways

  • @plamenyankov8476
    @plamenyankov8476 4 года назад +1

    Cheers! Thank you very much for the useful tutorial!!!
    Could somebody advise me how to make it work with some text in cyrilic.
    Many thanks in advance.

    • @CodingIsFun
      @CodingIsFun  4 года назад +2

      Thank you very much.
      I tried it out. For me, it is also working with Cyrillic (see sample code below).
      Alternatively, you could also install a font on your machine (which supports Cyrillic) and specify the path under "font_path".
      Let me know if that does not work for you.
      Cheers,
      Sven
      CODE BELOW 👇
      ---------------------------------------------------------------------------------------
      import matplotlib.pyplot as plt
      from wordcloud import WordCloud, STOPWORDS
      # Read text
      text = """Статья 1 Все люди рождаются свободными и равными в своем достоинстве и правах.
      Они наделены разумом и совестью и должны поступать в отношении друг друга в духе братства."""
      stopwords = STOPWORDS
      wc = WordCloud(
      background_color='white',
      stopwords=stopwords,
      # font_path='/Library/Fonts/NotoSansCJKjp-Light.otf',
      height = 600,
      width=400
      )
      wc.generate(text)
      # store to file
      wc.to_file('wordcloud_output.png')

  • @jamesstew6578
    @jamesstew6578 2 года назад

    awsome tutorial! but how do can you display 2 words together like " Red apple" or "Happy Smile"

    • @CodingIsFun
      @CodingIsFun  2 года назад

      Thank you for watching the video and for your question. Unfortunately, I do not know how to implement that right off the bat. I would also need to search the internet for a solution. Sorry that I cannot help!

    • @jamesstew6578
      @jamesstew6578 2 года назад

      @@CodingIsFun thanks alot for the answer. I will try to solve it, it is an good lesson to fix stuff by my own but it is hard tho xD

  • @dashvogel7212
    @dashvogel7212 2 года назад +1

    Hi, nice tutorial. :D
    Is it possible to add an transparent background?

    • @CodingIsFun
      @CodingIsFun  2 года назад +2

      Thanks!
      Here you are:
      wc = WordCloud(mode = "RGBA", background_color=None, height=600, width=400)

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

    Hey bro,
    How can I get word clouds in text format

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

      Thanks for watching. Off the top of my head, I'm not sure how to do that. You might need to do a little Google research. Good luck! Cheers, Sven ✌️

  • @fikrimuhammadf8673
    @fikrimuhammadf8673 4 года назад +3

    i can't install wordcloud in my python, why??

    • @CodingIsFun
      @CodingIsFun  4 года назад

      Do you receive any error message?

  • @ahmadnadeem870
    @ahmadnadeem870 2 года назад

    How to add hyperlink on words of cloud?

    • @CodingIsFun
      @CodingIsFun  2 года назад

      Thanks for watching the video and for your question! I'm sorry to say that I don't have the answer right off the top of my head. I'll need to do a little digging online to see if I can find a solution. Sorry I couldn't be more help!

    • @ahmadnadeem870
      @ahmadnadeem870 2 года назад

      Only heart!!! No hint😭

  • @Larzsolice
    @Larzsolice 2 года назад

    I have many documents and a list of words that are statistically significant across all the documents combined.
    I want to make a word cloud for each document class, feeding in a list of words and the average expression of those words within each set of documents.
    What function should I use?

    • @CodingIsFun
      @CodingIsFun  2 года назад

      Thank you for watching the video. Your questions are great, but finding the time to answer them is difficult. Kindly understand that I receive many requests for individual solutions or modifications. That said, you might want to join our Discord server ( pythonandvba.com/discord ) and post your question there. Thanks for your understanding. Happy Coding!

  • @aarihant2001
    @aarihant2001 3 года назад

    easy

  • @edgardoas5053
    @edgardoas5053 3 года назад

    Hi brother, how could I avoid spanish useless words. regards from Chile!

    • @CodingIsFun
      @CodingIsFun  3 года назад +3

      *Hello Edgardo AS, thanks for watching the video and your question.*
      You could provide a list of words [stopwords], which you would like to exclude. Kindly see the example below:
      stopwords = ['hola', 'soy', 'Sven']
      wc = WordCloud(
      background_color='white',
      stopwords=stopwords,
      height = 600,
      width=400
      )
      Hope it helps 🙏
      Cheers,
      Sven

    • @edgardoas5053
      @edgardoas5053 3 года назад +1

      Thanks a lot, it worked.