0

I have been trying to make a report using the dash package in Python, but there is an issue with the code starting from how I defined the figure. The data file has 2 columns with headers 'Name' and 'marks' where the 'Name' column is filled with string values and 'mark' with integers.

Debug = False as I am running this code on Spyder.

import dash
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd

Data = pd.read_csv(r'C:\Users\Karthik\Desktop\personal\python\data.csv', encoding = "ISO-8859-1")
app = dash.Dash()

app.layout = html.Div(children=[
    html.H1(children='Dash Tutorials'),
    dcc.Graph(id='example',
        figure={
            'data':[{'x': Data['Name'],'y':Data['marks'],'type'='line', 'name'='boats'} 
            ],
            'layout': {
                'title': 'Basic Dash Example'
            }
           } 
        )
])

if __name__ == '__main__':
    app.run_server(debug=False)
2
  • "theres an issue with the code" - what's the issue? Commented Apr 6, 2020 at 10:15
  • im not quite sure myself, the code analysis says its due to invalid syntax(pyflakes E) Commented Apr 6, 2020 at 10:36

1 Answer 1

0

This line has invalid syntax:

'data':[{'x': Data['Name'],'y':Data['marks'],'type'='line', 'name'='boats'} 

Entries in dictionary literals are defined like key: value, not key = value, so you should change it to this:

'data':[{'x': Data['Name'],'y': Data['marks'],'type': 'line', 'name': 'boats'}

If you want to use the key=value syntax anyway, the dict class supports it:

'data': [dict(
    x=Data['Name'],
    y=Data['marks'],
    type='line',
    name='boats'
)]
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.