i have serie:
print series.head() print type(series) print series.index year 1992 36.222222 1993 53.200000 1994 49.400000 1995 34.571429 1996 39.200000 name: ranking, dtype: float64 <class 'pandas.core.series.series'> int64index([1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014], dtype='int64', name=u'year')
i'm trying scatter plot, i'm having trouble accessing the index , values series.
any pointers appreciated.
i believe pandas series not support kind='scatter' if looking t0 call .plot() on series.
i believe lev's answer best , suitable use pandas. use matplotlib pyplot , works in similar way example.
import matplotlib.pyplot plt plt.scatter(ser.index, ser) plt.show()
perhaps try this:
import pandas pd import numpy np import matplotlib.pyplot plt np.random.seed(1) year = [1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014] value = np.random.rand(23) ser = pd.series(index = year,data=value) df =ser.to_frame() df.reset_index(inplace=true) df.columns = ['year','value'] df.plot(kind='scatter',x='year',y='value') plt.show()
Comments
Post a Comment