2017-05-06 64 views
0

所以我有一個數據框,其中'Art_Label'列具有文章分類的標籤,可能的值是:'politica','deportes','elmundo',' OTROS', 'policiales', 'economia', '編輯'直方圖上變量的標籤

這裏是從頂部

data = pd.read_csv('/filename.csv', sep=',') 
    data = data.drop('Unnamed: 0', axis=1) 
    data.columns 

指數([u'Date代碼 'u'Title' ,u'Encabezado',u'Art_Label',u'Media'],dtype ='object')

import matplotlib.pyplot as plt 
%matplotlib inline 

df = data['Art_Label'] 
df2 = df.value_counts() 
df2.plot(kind = 'hist', xlim = (0,400)) 
print df2 

我想創建一個每個標籤,它的頻率直方圖,我設法用'df2 = df.value_counts()'得到的頻率,我希望能夠得到直方圖的每個值的標籤:

這些都是我從'df2 = df.value_counts(取得)的成果「

politica  332 
deportes  323 
elmundo  192 
otros   191 
policiales 137 
economia  132 
editorial  96 
Name: Art_Label, dtype: int64 

回答

0

有點困惑你的問題。你想要這個數字嗎?如果是這樣,我覺得 '酒吧' 爲u想要什麼......

MM = pd.Series([332, 323, 192, 191, 137, 132, 96], index=['a', 'b', 'c', 'd', 'e', 'f', 'g']) 

MM.plot(kind = 'bar', xlim = (0,400)) 
plt.show() 

enter image description here