Home > database >  Plotting a bar plot with seaborn in python
Plotting a bar plot with seaborn in python

Time:11-20

The data frame I am using: enter image description here

The output I got is wrong as 1 should be 268 in count and 0 should be 500 in count. I don't know where I did the mistake.

CodePudding user response:

# encoding: utf-8

import pandas
import matplotlib.pyplot as plt
import seaborn as sns

diabetes = pandas.read_csv('diabetes.csv')


# solution one:
data = diabetes['Outcome'].value_counts()
sns.barplot(data.index, data.values)

# solution two:
sns.countplot(x='Outcome', data=diabetes)

  • Related