-1

I tried my first graph with sns.countplot and I had some issues/misunderstanding.

I have dataframe target:

A header Another header
0 1
1 0
2 1
611 1
612 0
613 0

Only with 0 and 1, for length = 614

    target.value_counts()
1 422  
0 192  

Now when I tried expose the result with sns.countplot(target)

I obtained this results :

Result

I was thinking of getting a chart with two separate columns (count 0 and the other column count 1).

I don't know where is the issue with my code.

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
Alx tbn
  • 1
  • 1
  • `ax = sns.countplot(data=target, x='Another header')` or `ax = sns.countplot(data=target['Another header'])` or `ax = target['Another header'].value_counts().plot(kind='bar', rot=0)` – Trenton McKinney Oct 09 '22 at 23:15

1 Answers1

-1

if you are looking to plot two bars, one for zeros and another for ones, you can use a barplot using the value_counts() you have shown in the question. Hope this is what you are looking for...

sns.barplot(x=target.value_counts().index, y = target.value_counts().values)
Redox
  • 9,321
  • 5
  • 9
  • 26