Python Seaborn - 2 | Creating a COUNT PLOT or FREQUENCY PLOT to See the Frequency Distribution

Поделиться
HTML-код
  • Опубликовано: 22 авг 2024

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

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

    To have numbers at bars/columns -
    import seaborn as sns
    import matplotlib.pyplot as plt
    # load the iris dataset
    iris = sns.load_dataset('iris')
    # create a count plot of the species column
    ax = sns.countplot(x='species', data=iris)
    # add count values to the bars
    for p in ax.patches:
    ax.annotate(format(p.get_height(), '.0f'), (p.get_x() + p.get_width() / 2., p.get_height()),
    ha = 'center', va = 'center', xytext = (0, 10), textcoords = 'offset points')
    plt.show()

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

    Wow, this is exactly what I needed thank you for explaining it so well!

  • @saswatachatterjee4213
    @saswatachatterjee4213 9 месяцев назад +1

    Thanks sir for this beautiful session...

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

    very nicely explained all , thanks

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

      Hope that helped. Keep watching

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

    Thank you.

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

    spot on tutorial thank u

  • @zeynabazimi7442
    @zeynabazimi7442 11 месяцев назад

    Hello. Thank you for all the useful videos. On 2:05, when you want to read the excel file, you have this drop down menu of functions. Could you let me know how you added it to jupyter notebook? Thanks.

    • @learnerea
      @learnerea  11 месяцев назад +1

      when you write "pd." just prcess Tab key from your keyboard and you will get that dropdown. Enjoy:)

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

    hey thanks for the video.. if i want the actual number in each of the bars how do it get it

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

      will make a video on this soon, in the meantime, you can use this for reference -
      www.geeksforgeeks.org/how-to-show-values-on-seaborn-barplot/

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

    Hey this tutorial is great, but I'm getting numbers on the labels for x-axis instead of column names on it. How do I fix this?

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

      try below -
      You may find it little lengthier, try the below -
      import seaborn as sns
      import matplotlib.pyplot as plt
      # load the iris dataset
      iris = sns.load_dataset('iris')
      # create a count plot of the species column
      ax = sns.countplot(x='species', data=iris)
      # add count values to the bars
      for p in ax.patches:
      ax.annotate(format(p.get_height(), '.0f'), (p.get_x() + p.get_width() / 2., p.get_height()),
      ha = 'center', va = 'center', xytext = (0, 10), textcoords = 'offset points')
      plt.show()

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

    If there is number on x-axis and count on y axis , how to give range for x axis, how to change range on y axis like (5,10, 15)

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

      Hi Uma,
      try below -
      sns.countplot(data=your_df,x="your_x_label_column")
      plt.ylim(min_number_you_want_to_start_from,max_number_you_want_to_start_from)
      for example, I have this data -
      data = {"Gender":[1,3,2,3,1,2,3,2,1,3,1],
      "Income":[80,34,40,45,50,90,70,60,45,40,85]}
      and I want to ploat "Gender" on x axis and want see the count in range between 3 to 12 then this is waht I'll do
      sns.countplot(data=df,x="Gender")
      plt.ylim(3,12)
      DO NOT FORGET TO IMPORT - import matplotlib.pyplot as plt
      let me know if this helps or not

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

    where is frequency distribution???countplot and fdist both are different right?

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

      What sort of frequency you actually want see, if you can give an example, possibly I'll be able to suggest you a better solution

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

    How would you add labels to the plot to indicate the actual number?

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

      You may find it little lengthier, try the below -
      import seaborn as sns
      import matplotlib.pyplot as plt
      # load the iris dataset
      iris = sns.load_dataset('iris')
      # create a count plot of the species column
      ax = sns.countplot(x='species', data=iris)
      # add count values to the bars
      for p in ax.patches:
      ax.annotate(format(p.get_height(), '.0f'), (p.get_x() + p.get_width() / 2., p.get_height()),
      ha = 'center', va = 'center', xytext = (0, 10), textcoords = 'offset points')
      plt.show()

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

    bro not getting suggestion on palette, producing error

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

      Suggseted in the comment on barplot.. alternatively you can also use -
      sns.color_palette
      to get the list

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

      me too now lol