Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
596 views
in Technique[技术] by (71.8m points)

python - Plot a histogram using the index as x-axis labels

I have the following dataframe in python

  Sex  Survived
0  female  0.742038
1    male  0.188908

i would like to plot a histogram, where male and female are the two values in the x-axis and y axis has its corresponding values. Any idea how ? . I am new to matplotlib and pandas, so please help

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In my opinion you need DataFrame.plot.bar:

df.plot.bar(x='Sex', y='Survived')

graph

because histogram plot distribution of numerical data.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...