Reputation: 783
I am trying to create a scatterplot of price vs. number for a certain year, say 2000.
I tried plotting with plt.plot(summary.price, summary.number, 'ro'), but I want it for a specific year so tried to only get the data from year 2000 with df['2000'] but it says key error.
How do I create a scatterplot with data from just a specific year?
Upvotes: 0
Views: 306
Reputation: 85603
To get the dataframe rows for index 2000 you can use:
df.xs(2000)
Other methods for selecting your data by the label of the index are:
df.loc[2000] # label based
df.ix[2000] # label and position based
Check Pandas docs for more information
Upvotes: 1