Line chartr-matplotlib

The line chart i did is different from the answer. Why did it happen?

Screen Link:

My Code:


You are doing great!

You just happen to plot the value more by 1. It should be unrate12=unrate.loc[0:11,:]

The answer shows unrated12=unrated12[0:12]

Now i get a little bit confused bewlow.


Hey @candiceliu93

To answer your question -

df[0:12] is a shorthand convention of df.iloc[0:12]. This will slice the rows from our dataframe(unrated12) based on integer positions.

df.loc[0:12] is primarily label based, it can access a group of rows and columns by label(s) or a boolean array.

I believe your confusion is clear now. Just in case, if you want to refresh/ brush up your skills on df.loc & df.iloc, i suggest you to quickly go through our courses:

Introduction to Pandas
Exploring data with Pandas - Intermediate


Got it now! After review the previous course, I think it help me to memories it firmly.

Thank you!!

1 Like

Awesome :blush: