I was studying python and came across something I'm not sure about. Here is the data frame.
year totalprod
0 1998 5.105093e+06
1 1999 4.706674e+06
2 2000 5.106000e+06
3 2001 4.221545e+06
4 2002 3.892386e+06
5 2003 4.122091e+06
6 2004 4.456805e+06
7 2005 4.243146e+06
8 2006 3.761902e+06
9 2007 3.600512e+06
10 2008 3.974927e+06
11 2009 3.626700e+06
12 2010 4.382350e+06
13 2011 3.680025e+06
14 2012 3.522675e+06
Before performing the scatter plot, the course was telling me to reshape x values, which are years.
Here is the code
X = prod_per_year['year']
X = X.values.reshape(-1,1)
y = prod_per_year['totalprod']
plt.scatter(X,y)
plt.show()
Why do we have to reshape before plotting? Aren't the values the same?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…