I want to scatter plot campcnt vs cnt by year, but I get error msg. How to fix this problem?
Thanks,
Jeff
Thanks,
Jeff
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
print (df.head()) app = dash.Dash() app.layout = html.Div([ dcc.Graph( id = 'life-exp-vs-gdp' , figure = { 'data' : [ go.Scatter( x = df[df[ 'year' ] = = i][ 'cntcamp' ], y = df[df[ 'year' ] = = i][ 'cnt' ], mode = 'markers' , opacity = 0.7 , marker = { 'size' : 15 , 'line' : { 'width' : 0.5 , 'color' : 'white' } }, name = i ) for i in df.year.unique() ], 'layout' : go.Layout( xaxis = { 'type' : 'log' , 'title' : 'Camp Count' }, yaxis = { 'title' : 'Total count' }, margin = { 'l' : 40 , 'b' : 40 , 't' : 10 , 'r' : 10 }, legend = { 'x' : 0 , 'y' : 1 }, hovermode = 'closest' ) } ) ]) |
Output: year cntcamp cnt
0 2015 36 347318781
1 2017 100 115586825
2 2016 48 59420381
3 2018 49 12924098
4 2014 6 2052933
Error:Traceback (most recent call last):
File "<ipython-input-8-ddb45a8148ad>", line 20, in <module>
) for i in df.year.unique()
AttributeError: 'SASdata' object has no attribute 'year'