2014-09-20 92 views
0

我想創建價格與數量某一年的散點圖,2000年說選擇從熊貓數據幀值和分級指數

我試着用plt.plot繪圖(summary.price,彙總'ro'),但我想要它在特定的一年,所以試圖只從2000年的數據獲得df ['2000'],但它說關鍵的錯誤。

如何用特定年份的數據創建散點圖?

enter image description here

回答

1

要獲得指數2000數據幀行,你可以使用:

df.xs(2000) 

由指數的標籤中選擇您的數據的其它方法有:

df.loc[2000] # label based 
df.ix[2000] # label and position based 

enter image description here

檢查Pandas docs更多信息

+0

它說關鍵錯誤 – user2491254 2014-09-20 19:05:41

+0

我轉載你的表,它的工作原理。 2000是一個字符串還是一個數字?檢查一下。 – joaquin 2014-09-20 19:12:33