简体   繁体   中英

How to create a histogram for a dataframe with just 1 column and multiple rows (row values should be plot on x axis and column values on y axis)

I am looking to plot histogram for the following dataframe (see below)

   |  missing_values
---------------
F1 | 123
F2 | 80
F3 | 0
.
.
F84| 20

with values represented as F1,F2,F3....F84 on x axis AND missing_Values represented on y axis Note: There is no column name associated to F1,F2...F84 as you see

Could someone advise on how to create a histogram for this? IS there any manipulation i need to do before i can plot histogram. I am not able to figure out what is needed

You can try:

import matplotlib.pyplot as plt

plt.bar(x=df.index.values, height=df.missing_values.values)

If you ever need to transform the index in a ordinary column, you can use df.reset_index(inplace=True)

If your index (the first column) is sorted you can use a bar chart:

df.plot.bar()

or

df.plot(kind='bar')

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM