0

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?

enter image description here

0

1 Answer 1

1

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 

enter image description here

Check Pandas docs for more information

Sign up to request clarification or add additional context in comments.

1 Comment

I reproduced your table and it works. Is 2000 a string or a number ? check that.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.