Histogram of a dataframe

user8650813

I have a data frame as follow: enter image description here

and I am trying to plot a histogram from it such that the letters {A,B,C,D} are in the x axis and y axis shows the numbers. I have tried the following:

df.plot(kind='hist')

for which I get the address instead of the plot, i.e:

<matplotlib.axes._subplots.AxesSubplot at 0x11217d5f8>

I was wondering how can I show the plot?

Sandeep Kadapa

IIUC, I think you need to transpose the dataframe to get index ['A','B','C','D']as x-axis and then plot. Also use plt.show() to display the histogram. The latest version of pandas will display directly the plot with axes object displaying. But, for the older versions need to explicitly write the plt.show() code to display.

import matplotlib.pyplot as plt
df.T.plot(kind='hist')
plt.show()

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Histogram of dataframe on column groupby

Python Pandas histogram with dataframe

Histogram of a pandas dataframe

Get bins of histogram in a pandas dataframe

Panda dataframe : plot histogram with grouping

Plotting histogram using seaborn for a dataframe

Stacked histogram by decade from dataframe

Show histogram in Python from dataframe

Cumulative histogram plot from dataframe

Plot stacked histogram with grouped DataFrame

Making histogram of object attribute of a DataFrame

Compare two dataframe columns on a histogram

histogram of dataframe columns side-by-side

How to make a histogram from all of the values in a dataframe?

Generating an histogram with Matplotlib using a dataframe for x and y

Seaborn - remove spacing from DataFrame histogram

Plot a histogram based on a value in a column of a dataframe

How to plot histogram with data prepared in Pandas DataFrame?

PySpark create histogram dataframe for DecimalType column

Create a seaborn histogram with two columns of a dataframe

How to plot a two column pandas dataframe's elements as an histogram?

How to show the names of columns of a dataframe in the axes in a Python histogram?

How to group columns by label in a histogram using a panda DataFrame?

Plotting histogram of Pandas Dataframe with its mean and standard deviation, getting ValueError

How to plot stacked time histogram starting from a Pandas DataFrame?

Plotting already sorted histogram data stored in a panda dataframe

Creating a histogram for each value in multi-index pandas dataframe

Sorting datetime objects by hour to a Pandas dataframe, then visualize to histogram with Matplotlib

How to make sub sub plots of pandas dataframe for histogram